概述
Network Charts可能会起作用。查看Networkx docs获取更多详细信息。这也是为大型网络而设计的,但是如果结合几个例子,可以对其进行一些定制,作为流程图。我可以通过一点挖掘来创建这个,它可以作为一个不错的流程图模板。在import pandas as pd
import networkx as nx
import matplotlib.pyplot as plt
plt.figure(figsize = (12,9))
From = ['FoodnProduction', 'Transportation', 'EnergynProduction',
"GreenhousenGasnEmissions",'ClimatenChange','ClimatenFeedbacks','GreenhousenGasnEmissions',
'ClimatenChange']
To = ["GreenhousenGasnEmissions", "GreenhousenGasnEmissions",
"GreenhousenGasnEmissions",'ClimatenChange','ClimatenFeedbacks','GreenhousenGasnEmissions',
'ClimatenChange','Everyone$^{Dies}$']
df = pd.DataFrame({ 'from':From,
'to':To})
# Define Node Positions
pos = {'FoodnProduction':(1,1),
'Transportation':(1,2),
'EnergynProduction':(1,3),
'GreenhousenGasnEmissions':(2,2),
'ClimatenChange':(3,2),
'ClimatenFeedbacks':(2.5,3),
'Everyone$^{Dies}$':(4,2)}
# Define Node Colors
NodeColors = {'FoodnProduction':[1,0,1],
'Transportation':[1,1,0],
'EnergynProduction':[0,1,1],
'GreenhousenGasnEmissions':[1,.5,1],
'ClimatenChange':[0,1,0],
'ClimatenFeedbacks':[0,0,1],
'Everyone$^{Dies}$':[1,0,0]}
Labels = {}
i = 0
for a in From:
Labels[a]=a
i +=1
Labels[To[-1]]=To[-1]
# Build your graph. Note that we use the DiGraph function to create the graph! This adds arrows
G=nx.from_pandas_edgelist(df, 'from', 'to', create_using=nx.DiGraph() )
# Define the colormap and set nodes to circles, but the last one to a triangle
Circles = []
Traingle = []
Colors = []
for n in G.nodes:
if n != 'Everyone$^{Dies}$':
Circles.append(n)
else:
Traingle.append(n)
Colors.append(NodeColors[n])
# By making a white node that is larger, I can make the arrow "start" beyond the node
nodes = nx.draw_networkx_nodes(G, pos,
nodelist = Circles,
node_size=1.25e4,
node_shape='o',
node_color='white',
alpha=1)
nodes = nx.draw_networkx_nodes(G, pos,
nodelist = Circles,
node_size=1e4,
node_shape='o',
node_color=Colors,
edgecolors='black',
alpha=0.5)
nodes = nx.draw_networkx_nodes(G, pos,
nodelist = Traingle,
node_size=1.25e4,
node_shape='>',
node_color='white',
alpha=1)
nodes = nx.draw_networkx_nodes(G, pos,
nodelist = Traingle,
node_size=1e4,
node_shape='>',
node_color=Colors,
edgecolors='black',
alpha=0.5)
nx.draw_networkx_labels(G, pos, Labels, font_size=12)
# Again by making the node_size larer, I can have the arrows end before they actually hit the node
edges = nx.draw_networkx_edges(G, pos, node_size=1.8e4,
arrowstyle='->',width=2,arrowsizes=10)
plt.xlim(0,4.5)
plt.ylim(0,4)
plt.axis('off')
plt.show()
最后
以上就是疯狂宝马为你收集整理的python录音流程图_Python绘制流程图、图解图的全部内容,希望文章能够帮你解决python录音流程图_Python绘制流程图、图解图所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复