Flowcharts exist in every aspect of our lives. They are of great help to us in tracking the progress of projects and making decisions on various things. As for the almighty Python, Drawing flow charts is also very easy. Today I will introduce to you two modules for drawing flow charts. Let’s look at the first one first.
SchemDraw
So in the SchemDraw module, there are six elements used to represent the main nodes of the flow chart. The ovals represent the beginning and end of the decision. , the code is as follows:
import schemdraw from schemdraw.flow import * with schemdraw.Drawing() as d: d += Start().label("Start")
output
The arrow represents the direction of decision-making and is used to connect each node. The code is as follows:
with schemdraw.Drawing() as d: d += Arrow(w = 5).right().label("Connector")
output
The parallelogram represents the problem you have to deal with and solve, and the rectangle represents the effort you have to make for it. The effort or process, the code is as follows:
with schemdraw.Drawing() as d: d += Data(w = 5).label("What's the problem")
output
##
with schemdraw.Drawing() as d: d += Process(w = 5).label("Processing")output
with schemdraw.Drawing() as d: d += Decision(w = 5).label("Decisions")output
import schemdraw from schemdraw.flow import * with schemdraw.Drawing() as d: d+= Start().label("Start") d+= Arrow().down(d.unit/2) # 具体是啥问题嘞 d+= Data(w = 4).label("Go camping or not") d+= Arrow().down(d.unit/2) # 第一步 查看天气 d+= Box(w = 4).label("Check weather first") d+= Arrow().down(d.unit/2) # 是否是晴天 d+= (decision := Decision(w = 5, h= 5, S = "True", E = "False").label("See if it's sunny")) # 如果是真的话 d+= Arrow().length(d.unit/2) d+= (true := Box(w = 5).label("Sunny, go camping")) d+= Arrow().length(d.unit/2) # 结束 d+= (end := Ellipse().label("End")) # 如果不是晴天的话 d+= Arrow().right(d.unit).at(decision.E) # 那如果是下雨天的话,就不能去露营咯 d+= (false := Box(w = 5).label("Rainy, stay at home")) # 决策的走向 d+= Arrow().down(d.unit*2.5).at(false.S) # 决策的走向 d+= Arrow().left(d.unit*2.15) d.save("palindrome flowchart.jpeg", dpi = 300)output
import networkx as nx import matplotlib.pyplot as plt import numpy as np G = nx.DiGraph() nodes = np.arange(0, 8).tolist() G.add_nodes_from(nodes) # 节点连接的信息,哪些节点的是相连接的 G.add_edges_from([(0,1), (0,2), (1,3), (1, 4), (2, 5), (2, 6), (2,7)]) # 节点的位置 pos = {0:(10, 10), 1:(7.5, 7.5), 2:(12.5, 7.5), 3:(6, 6), 4:(9, 6), 5:(11, 6), 6:(14, 6), 7:(17, 6)} # 节点的标记 labels = {0:"CEO", 1: "Team A Lead", 2: "Team B Lead", 3: "Staff A", 4: "Staff B", 5: "Staff C", 6: "Staff D", 7: "Staff E"} nx.draw_networkx(G, pos = pos, labels = labels, arrows = True, node_shape = "s", node_color = "white") plt.title("Company Structure") plt.show()output
nx.draw_networkx(G, pos = pos, labels = labels, bbox = dict(facecolor = "skyblue", boxstyle = "round", ec = "silver", pad = 0.3), edge_color = "gray" ) plt.title("Company Structure") plt.show()output
The above is the detailed content of Draw some interesting visualization charts in Python. For more information, please follow other related articles on the PHP Chinese website!

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于Seaborn的相关问题,包括了数据可视化处理的散点图、折线图、条形图等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于进程池与进程锁的相关问题,包括进程池的创建模块,进程池函数等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于简历筛选的相关问题,包括了定义 ReadDoc 类用以读取 word 文件以及定义 search_word 函数用以筛选的相关内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于数据类型之字符串、数字的相关问题,下面一起来看一下,希望对大家有帮助。

VS Code的确是一款非常热门、有强大用户基础的一款开发工具。本文给大家介绍一下10款高效、好用的插件,能够让原本单薄的VS Code如虎添翼,开发效率顿时提升到一个新的阶段。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于numpy模块的相关问题,Numpy是Numerical Python extensions的缩写,字面意思是Python数值计算扩展,下面一起来看一下,希望对大家有帮助。

pythn的中文意思是巨蟒、蟒蛇。1989年圣诞节期间,Guido van Rossum在家闲的没事干,为了跟朋友庆祝圣诞节,决定发明一种全新的脚本语言。他很喜欢一个肥皂剧叫Monty Python,所以便把这门语言叫做python。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver Mac version
Visual web development tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft
