当前位置:网站首页>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()
边栏推荐
- Mybatis的引入问题invalid
- 在出海获客这件事上,数字广告投放之外,广告主还能怎么玩儿?
- [LOJ 6718] nine suns' weakened version (cyclic convolution, arbitrary modulus NTT)
- 商城风格也可以很多变,DIY 了解一下
- [paper notes] learning to grasp with primitive shaped object policies
- Small record of neural network learning 71 - tensorflow2 deep learning with Google Lab
- Open camera anomaly analysis (I)
- ASP. Net core introduction
- mysql存儲過程
- Uni app custom navigation bar component
猜你喜欢
ABP framework Practice Series (I) - Introduction to persistence layer
MySQL高級篇第一章(linux下安裝MySQL)【下】
[paper notes] learning to grasp with primitive shaped object policies
String到底能不能改变?
Uni app Baidu cloud realizes OCR ID card recognition
Oracle技术分享 oracle 19.14升级19.15
. Net core learning journey
Intelligent manufacturing learning videos and books
Open Camera异常分析(一)
Camera-CreateCaptureSession
随机推荐
ABP framework
ABP framework Practice Series (III) - domain layer in depth
An error occurred using the connection to database 'on server' 10.28.253.2‘
MySQL advanced part (IV: locking mechanism and SQL optimization)
MapReduce执行原理记录
神经网络学习小记录71——Tensorflow2 使用Google Colab进行深度学习
2022.6.25-----leetcode.剑指offer.091
(15) Blender source code analysis flash window display menu function
Oracle技术分享 oracle 19.14升级19.15
How to solve the problem that iterative semi supervised training is difficult to implement in ASR training? RTC dev Meetup
2022.6.23-----leetcode.30
Quanergy欢迎Lori Sundberg出任首席人力资源官
The style of the mall can also change a lot. DIY can learn about it
2022.6.25 - leetcode. Un doigt d'épée. 091.
763. dividing alphabetic intervals
Kotlin learning apply plugin: 'kotlin Android extensions‘
169. most elements
评价——层次分析
Restful API interface design standards and specifications
刷题记录Day01