是否有Python库来绘制流程图,插图如:
答案 0 :(得分:1)
您可以使用Schemdraw。尽管它的主要目的是生成高质量的电路原理图,但其中的一部分可用于绘制流程图。
例如: https://schemdraw.readthedocs.io/en/latest/gallery/flowcharting.html#galleryflow
答案 1 :(得分:0)
您可能想尝试PyDot: https://code.google.com/p/pydot/
我还没有尝试过python版本,但我过去使用过Graphviz而且非常好。
答案 2 :(得分:0)
Network Charts可能会成功。请查看Networkx docs了解更多详细信息。这也适用于大型网络,但是如果您结合其中的一些示例,则可以对其进行一些自定义以用作流程图。我能够稍加挖掘就可以创建它,它可以作为流程图的一个不错的模板。
import pandas as pd
import networkx as nx
import matplotlib.pyplot as plt
plt.figure(figsize = (12,9))
From = ['Food\nProduction', 'Transportation', 'Energy\nProduction',
"Greenhouse\nGas\nEmissions",'Climate\nChange','Climate\nFeedbacks','Greenhouse\nGas\nEmissions',
'Climate\nChange']
To = ["Greenhouse\nGas\nEmissions", "Greenhouse\nGas\nEmissions",
"Greenhouse\nGas\nEmissions",'Climate\nChange','Climate\nFeedbacks','Greenhouse\nGas\nEmissions',
'Climate\nChange','Everyone$^{Dies}$']
df = pd.DataFrame({ 'from':From,
'to':To})
# Define Node Positions
pos = {'Food\nProduction':(1,1),
'Transportation':(1,2),
'Energy\nProduction':(1,3),
'Greenhouse\nGas\nEmissions':(2,2),
'Climate\nChange':(3,2),
'Climate\nFeedbacks':(2.5,3),
'Everyone$^{Dies}$':(4,2)}
# Define Node Colors
NodeColors = {'Food\nProduction':[1,0,1],
'Transportation':[1,1,0],
'Energy\nProduction':[0,1,1],
'Greenhouse\nGas\nEmissions':[1,.5,1],
'Climate\nChange':[0,1,0],
'Climate\nFeedbacks':[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()
答案 3 :(得分:-1)
您可以尝试Creately。它是绘制图表并使其非常适合您的用途的最佳用户友好软件之一。