当前位置:网站首页>Matplotlib multi line chart, dot scatter chart
Matplotlib multi line chart, dot scatter chart
2022-06-26 03:54:00 【starmultiple】
matplotlib Line chart scatter chart
Single polyline
# coding=utf-8
from matplotlib import pyplot as plt
plt.rcParams['font.sans-serif'] = ['Microsoft YaHei']
x=range(11,31)
y=[1,0,1,1,2,4,3,2,3,4,4,5,6,5,4,3,3,1,1,1]
# Set graphic size
plt.figure(figsize=(20,8),dpi=80)
plt.plot(x,y)# draw xy
# Set up x Axis scale
_xtick_labels=["{} year ".format(i) for i in x]
plt.xticks(x,_xtick_labels)
plt.yticks(range(0,9))
# Draw mesh
plt.grid(alpha=0.2)# transparency
# Exhibition
plt.show()

Polygonal line
# coding=utf-8
from matplotlib import pyplot as plt
plt.rcParams['font.sans-serif'] = ['Microsoft YaHei']
x=range(11,31)
y1=[1,0,1,1,2,4,3,2,3,4,4,5,6,5,4,3,3,1,1,1]
y2=[1,0,3,1,2,2,3,3,2,1,2,1,1,1,1,1,1,1,1,1]
# Set graphic size
plt.figure(figsize=(20,8),dpi=80)
plt.plot(x,y1,label="y1")# draw xy
plt.plot(x,y2,label="y2")
# Set up x Axis scale
_xtick_labels=["{} year ".format(i) for i in x]
plt.xticks(x,_xtick_labels)
plt.yticks(range(0,9))
# Draw mesh
plt.grid(alpha=0.2)# transparency
# Add legend
plt.legend()
# Exhibition
plt.show()
Enrich
# coding=utf-8
from matplotlib import pyplot as plt
plt.rcParams['font.sans-serif'] = ['Microsoft YaHei']
x=range(11,31)
y1=[1,0,1,1,2,4,3,2,3,4,4,5,6,5,4,3,3,1,1,1]
y2=[1,0,3,1,2,2,3,3,2,1,2,1,1,1,1,1,1,1,1,1]
# Set graphic size
plt.figure(figsize=(20,8),dpi=80)
plt.plot(x,y1,label="y1",color="orange",linestyle=':',linewidth=10)# draw xy
plt.plot(x,y2,label="y2",color="cyan",linestyle='--',linewidth=5)
# color Color linestyle Line style linewidth Line width
# Set up x Axis scale
_xtick_labels=["{} year ".format(i) for i in x]
plt.xticks(x,_xtick_labels)
plt.yticks(range(0,9))
# Draw mesh
plt.grid(alpha=0.2)# transparency
# Add legend , Place the legend on the left
plt.legend(loc="upper left")
# Exhibition
plt.show()
Electric scatter diagram
The law of temperature and weather change
from matplotlib import pyplot as plt
plt.rcParams['font.sans-serif'] = ['Microsoft YaHei']
y_a=[11,17,16,11,12,11,12,6,6,7,8,9,12,15,14,17,18,21,16,17,20,14,15,15,15,19,21,22,23]
y_b=[26,26,28,19,21,17,16,19,18,20,20,19,22,23,17,20,21,20,22,15,11,5,13,17,10,11,13,12,13,6]
x_a=range(1,30)
x_b=range(41,71)
# Set graphic size
plt.figure(figsize=(20,8),dpi=80)
plt.scatter(x_a,y_a,label=" March ")
plt.scatter(x_b,y_b,label="10 month ")
# adjustment x Axis scale
_x=list(x_a)+list(x_b)
_xtick_labels=["3 month {} Japan ".format(i) for i in x_a]
_xtick_labels+=["10 month {} Japan ".format(i-50) for i in x_b]
plt.xticks(_x[::1],_xtick_labels[::1],rotation=45)
# Add legend
plt.legend(loc="upper left")
# Add a description
plt.xlabel(" Time ")
plt.ylabel(" temperature ")
plt.title(" title ")
plt.show()

边栏推荐
- Camera-CreateCaptureSession
- Pay attention to the entrance components of official account in the applet
- 169. most elements
- MySQL高级部分( 四: 锁机制、SQL优化 )
- Custom parameter QR code picture combined with background picture to generate new picture node environment
- 2022.6.25 - leetcode. Un doigt d'épée. 091.
- 2020 summary: industrial software development under Internet thinking
- An error occurred using the connection to database 'on server' 10.28.253.2‘
- MySQL高级篇第一章(linux下安装MySQL)【下】
- 外包干了四年,人直接废了。。。
猜你喜欢

Intelligent manufacturing learning videos and books
![[LOJ 6718] nine suns' weakened version (cyclic convolution, arbitrary modulus NTT)](/img/fd/0c299b7cc728f2d6274eea30937726.png)
[LOJ 6718] nine suns' weakened version (cyclic convolution, arbitrary modulus NTT)

After Ali failed to start his job in the interview, he was roast by the interviewer in the circle of friends (plug)

Small record of neural network learning 71 - tensorflow2 deep learning with Google Lab

TiFlash 函数下推必知必会丨十分钟成为 TiFlash Contributor

【Flink】Flink源码分析——批处理模式JobGraph的创建

Quanergy欢迎Lori Sundberg出任首席人力资源官

Can string be changed?

"Renegotiation" agreement

ABP framework Practice Series (II) - Introduction to domain layer
随机推荐
使用SOAPUI访问对应的esb工程
Uni app custom selection date 2 (September 16, 2021)
MySQL的视图
User control custom DependencyProperty
用eclipse连mysql数据库出错然后出现图中的话是咋回事呀
[MySQL] MySQL export database
763. 划分字母区间
Camera memory memory leak analysis (III)
面试阿里测开岗失败后,被面试官在朋友圈吐槽了......(心塞)
1.基础关
【Flink】Flink Sort-Shuffle写流程简析
Uni app, the text implementation expands and retracts the full text
MapReduce执行原理记录
Solve the problem that the input box is blocked by the pop-up keyboard under the WebView transparent status bar
MySQL advanced Chapter 1 (installing MySQL under Linux) [2]
刷题记录Day01
QPS的概念和实现
Webrtc series - 6-connections tailoring for network transmission
2022.6.25-----leetcode. Sword finger offer 091
. Net core learning journey