本文整理汇总了Python中pygraphviz.AGraph.node_attr['fontname']方法的典型用法代码示例。如果您正苦于以下问题:Python AGraph.node_attr['fontname']方法的具体用法?Python AGraph.node_attr['fontname']怎么用?Python AGraph.node_attr['fontname']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygraphviz.AGraph
的用法示例。
在下文中一共展示了AGraph.node_attr['fontname']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot
# 需要导入模块: from pygraphviz import AGraph [as 别名]
# 或者: from pygraphviz.AGraph import node_attr['fontname'] [as 别名]
def plot(table_names=None):
"""
Plot relationships between columns and tables using Graphviz.
Parameters
----------
table_names : iterable of str, optional
Names of UrbanSim registered tables to plot.
Defaults to all registered tables.
Returns
-------
graph : pygraphviz.AGraph
PyGraphviz graph object.
"""
if not table_names:
# Default to all registered tables.
table_names = simulation.list_tables()
graph = AGraph(directed=True)
graph.graph_attr['fontname'] = 'Sans'
graph.graph_attr['fontsize'] = 28
graph.node_attr['shape'] = 'box'
graph.node_attr['fontname'] = 'Sans'
graph.node_attr['fontcolor'] = 'blue'
graph.edge_attr['weight'] = 2
# Add each registered table as a subgraph with columns as nodes.
for table_name in table_names:
subgraph = graph.add_subgraph(name='cluster_' + table_name,
label=table_name, fontcolor='red')
table = simulation.get_table(table_name)
for column_name in table.columns:
full_name = table_name + '.' + column_name
subgraph.add_node(full_name, label=column_name)
# Iterate over computed columns to build nodes.
for key, wrapped_col in simulation._COLUMNS.items():
table_name = key[0]
column_name = key[1]
# Combine inputs from argument names and argument default values.
args = list(wrapped_col._argspec.args)
if wrapped_col._argspec.defaults:
default_args = list(wrapped_col._argspec.defaults)
else:
default_args = []
inputs = args[:len(args) - len(default_args)] + default_args
# Create edge from each input column to the computed column.
for input_name in inputs:
full_name = table_name + '.' + column_name
graph.add_edge(input_name, full_name)
graph.layout(prog='dot')
return graph