コード例 #1
0
ファイル: ts.py プロジェクト: xli4217/reactive-twtl
 def visualize(self,
               edgelabel='control',
               current_node=None,
               draw='pygraphviz'):
     """
     Visualizes a LOMAP system model.
     """
     assert edgelabel is None or nx.is_weighted(self.g, weight=edgelabel)
     if draw == 'pygraphviz':
         nx.view_pygraphviz(self.g, edgelabel)
     elif draw == 'matplotlib':
         pos = nx.get_node_attributes(self.g, 'location')
         if len(pos) != self.g.number_of_nodes():
             pos = nx.spring_layout(self.g)
         if current_node is None:
             colors = 'r'
         else:
             if current_node == 'init':
                 current_node = next(self.init.iterkeys())
             colors = dict([(v, 'r') for v in self.g])
             colors[current_node] = 'b'
             colors = colors.values()
         nx.draw(self.g, pos=pos, node_color=colors)
         nx.draw_networkx_labels(self.g, pos=pos)
         edge_labels = nx.get_edge_attributes(self.g, edgelabel)
         nx.draw_networkx_edge_labels(self.g,
                                      pos=pos,
                                      edge_labels=edge_labels)
     else:
         raise ValueError('Expected parameter draw to be either:' +
                          '"pygraphviz" or "matplotlib"!')
コード例 #2
0
ファイル: ts.py プロジェクト: wasserfeder/lomap
 def visualize(self, edgelabel='control', current_node=None,
               draw='pygraphviz'):
     """
     Visualizes a LOMAP system model.
     """
     assert edgelabel is None or nx.is_weighted(self.g, weight=edgelabel)
     if draw == 'pygraphviz':
         nx.view_pygraphviz(self.g, edgelabel)
     elif draw == 'matplotlib':
         pos = nx.get_node_attributes(self.g, 'location')
         if len(pos) != self.g.number_of_nodes():
             pos = nx.spring_layout(self.g)
         if current_node is None:
             colors = 'r'
         else:
             if current_node == 'init':
                 current_node = next(self.init.iterkeys())
             colors = dict([(v, 'r') for v in self.g])
             colors[current_node] = 'b'
             colors = colors.values()
         nx.draw(self.g, pos=pos, node_color=colors)
         nx.draw_networkx_labels(self.g, pos=pos)
         edge_labels = nx.get_edge_attributes(self.g, edgelabel)
         nx.draw_networkx_edge_labels(self.g, pos=pos,
                                      edge_labels=edge_labels)
     else:
         raise ValueError('Expected parameter draw to be either:'
                          + '"pygraphviz" or "matplotlib"!')
コード例 #3
0
    def visualize(self,
                  edgelabel=None,
                  draw='pydot',
                  save_path=None,
                  dot_file_name="g",
                  svg_file_name="file"):
        """
        Visualizes a LOMAP system model
        """
        if draw == 'pygraphviz':
            nx.view_pygraphviz(self.g, edgelabel)
        # elif draw == 'matplotlib':
        #     pos = nx.spring_layout(self.g)
        #     nx.draw(self.g, pos=pos)
        #     nx.draw_networkx_labels(self.g, pos=pos)
        #     plt.savefig('path.png')
        elif draw == 'pydot':
            if save_path is None:
                write_dot(self.g, dot_file_name + ".dot")
                os.system('dot -Tsvg ' + dot_file_name + '.dot -o ' +
                          svg_file_name + '.svg')
            else:
                dot_file_path = os.path.join(save_path, dot_file_name + ".dot")
                svg_file_path = os.path.join(save_path, svg_file_name + '.svg')
                write_dot(self.g, dot_file_path)
                os.system('dot -Tsvg ' + dot_file_path + ' -o ' +
                          svg_file_path)

        else:
            raise ValueError('Expected parameter draw to be either:' +
                             '"pygraphviz" or "matplotlib" or "pydot"!')
コード例 #4
0
ファイル: model.py プロジェクト: wasserfeder/lomap
 def visualize(self, edgelabel=None, draw='pygraphviz'):
     """
     Visualizes a LOMAP system model
     """
     if draw == 'pygraphviz':
         nx.view_pygraphviz(self.g, edgelabel)
     elif draw == 'matplotlib':
         pos = nx.spring_layout(self.g)
         nx.draw(self.g, pos=pos)
         nx.draw_networkx_labels(self.g, pos=pos)
     else:
         raise ValueError('Expected parameter draw to be either:'
                          + '"pygraphviz" or "matplotlib"!')
コード例 #5
0
ファイル: model.py プロジェクト: pete9936/pyTWTL_ObsAvoid
    def visualize(self, edgelabel=None, draw='pygraphviz'):
        """
		Visualizes a LOMAP system model
		"""
        if draw == 'pygraphviz':
            nx.view_pygraphviz(self.g, edgelabel)
        elif draw == 'matplotlib':
            pos = nx.spring_layout(self.g)
            nx.draw(self.g, pos=pos)
            nx.draw_networkx_labels(self.g, pos=pos)
        else:
            raise ValueError('Expected parameter draw to be either:' +
                             '"pygraphviz" or "matplotlib"!')
コード例 #6
0
ファイル: ts.py プロジェクト: pete9936/pyTWTL_ObsAvoid
    def visualize(self):
        """
		Visualizes a LOMAP system model
		"""
        nx.view_pygraphviz(self.g, 'control')
コード例 #7
0
    tokens3[i]=tokens3[i].replace(".","").replace(",","")


text3 = k.Text(tokens3)
#participação social; sociedade civil; presidência república;
#secretaria-geral presidência; planejamento orçamento; mecanismos
#participação; educação cidadania; movimentos sociais; deste
#compromisso; cidadania ativa; entes signatários; secretaria nacional;
#conferências nacionais; dias após; nacionais ouvidorias; sobre
#temas; consultas públicas; meio secretaria; presente compromisso;
#organizações sociedade

ff=text3.vocab()
N=80
yy=ff.values()[:N]
xx=ff.keys()[:N]
p.title(u"Ocorrências de palavras")
p.plot(n.arange(len(yy)),yy,"ro")
p.ylabel(u"ocorrências")
p.xlabel(u"palavras")
p.xticks(n.arange(len(yy)),[x.decode("utf-8") for x in xx],rotation=80)
p.xlim(-1,len(yy)+1)
p.show()

import networkx as x
G=x.Graph()

for i in xrange(len(tokens3)-1):
    G.add_edge(tokens3[i].decode("utf-8"),tokens3[i+1].decode("utf-8"))
x.view_pygraphviz(G)
コード例 #8
0
ファイル: markov.py プロジェクト: wasserfeder/gdtl-firm
	def visualize(self):
		"""
		Visualizes a LOMAP system model
		"""
		nx.view_pygraphviz(self.g, 'prob')