当前位置:网站首页>Matplotlib line chart, text display, win10
Matplotlib line chart, text display, win10
2022-06-26 03:54:00 【starmultiple】
matplotlib
matplotlib: One of the most popular Python Bottom drawing library , Mainly for data visualization chart , The name comes from MATLAB, imitation MATLAB structure
from matplotlib import pyplot as plt# Import pyplot
#figure Represents a graphic icon
#dpi It refers to the number of pixels per inch
x=range(2,26,2)
# Definition x Axis 2~24 In steps of 2
y=[14,13,14.5,17,2,23,25,26,24,22,18,15]
# Set picture size
fig =plt.figure(figsize=(20,8),dpi=80)
# mapping
plt.plot(x,y)
# draw x The axis scale cannot be used directly here 0.5 The step size is therefore defined as follows
_xtick_labels=[i/2 for i in range(4,49)]
plt.xticks(range(2,27))
plt.xticks(range(min(y),max(y)+1))
# Save the picture
plt.savefig("./sig_size.png")# Can be saved as svg This vector graph format , Zoom in without jagging
plt.show()
problem :
If the list a Express 10 Point to 12 The temperature of every minute of the hour , How to draw a line chart to observe the change of temperature every minute ?
a=[random.randlint(20,35) for i in range(120)]
from matplotlib import pyplot as plt
import random# Random function
x=range(0,120)
y=[random.randint(20,35) for i in range(120)]
plt.figure(figsize=(20,8),dpi=80)
plt.plot(x,y)
# adjustment x Axis scale
_x=list(x)
_xtick_labels=["10 spot {} branch ".format(i) for i in range(60)]
_xtick_labels+=["11 spot {} branch ".format(i) for i in range(60)]
# Step size
plt.xticks(_x[::3],_xtick_labels[::3],rotation=45)#rotation=45 rotate 45°
plt.show()
Set Chinese display Law 1 :( recommend )
from matplotlib import pyplot as plt
import random# Random function
#!! Just this line
plt.rcParams['font.sans-serif'] = ['Microsoft YaHei']
x=range(0,120)
y=[random.randint(20,35) for i in range(120)]
plt.figure(figsize=(20,8),dpi=80)
plt.plot(x,y)
# adjustment x Axis scale
_x=list(x)
_xtick_labels=["10 spot {} branch ".format(i) for i in range(60)]
_xtick_labels+=["11 spot {} branch ".format(i) for i in range(60)]
# Step size
plt.xticks(_x[::3],_xtick_labels[::3],rotation=45) #rotation=45 rotate 45°
# Add a description
plt.xlabel(' Time ')
plt.ylabel(' temperature : Company (℃)')
plt.title(' Temperature change from ten to twelve ')
plt.show()
Law two :
from matplotlib import pyplot as plt
import random# Random function
from matplotlib import font_manager
# Another way to set the font
my_font=font_manager.FontProperties(fname='C:\WINDOWS\FONTS\MSYHL.TTC')
x=range(0,120)
y=[random.randint(20,35) for i in range(120)]
plt.figure(figsize=(20,8),dpi=80)
plt.plot(x,y)
# adjustment x Axis scale
_x=list(x)
_xtick_labels=["10 spot {} branch ".format(i) for i in range(60)]
_xtick_labels+=["11 spot {} branch ".format(i) for i in range(60)]
# Step size
plt.xticks(_x[::3],_xtick_labels[::3],rotation=45,fontproperties=my_font)#rotation=45 rotate 45°
# Add a description
plt.xlabel(" Time ",fontproperties=my_font)
plt.ylabel(" temperature Company (℃)",fontproperties=my_font)
plt.title("10 Point to 12 Temperature changes per minute at the point ",fontproperties=my_font)
plt.show()
边栏推荐
- WPF 值转换
- Detr3d multi 2D picture 3D detection framework
- Uni app QR code scanning and identification function
- 神经网络学习小记录71——Tensorflow2 使用Google Colab进行深度学习
- Uni app custom navigation bar component
- 【好书集锦】从技术到产品
- Binary search method
- You cannot call Glide. get() in registerComponents(), use the provided Glide instance instead
- (15)Blender源码分析之闪屏窗口显示菜单功能
- Webrtc series - 6-connections tailoring for network transmission
猜你喜欢
Camera memory memory leak analysis (III)
高性能算力中心 — RoCE — Overview
MapReduce执行原理记录
Machine learning notes - trend components of time series
[Flink] Flink batch mode map side data aggregation normalizedkeysorter
Alibaba cloud function computing service one click to build Z-blog personal blog
Uni app custom selection date 1 (September 16, 2021)
优化——多目标规划
TiFlash 函数下推必知必会丨十分钟成为 TiFlash Contributor
ABP framework
随机推荐
2022.6.25-----leetcode. Sword finger offer 091
C # knowledge structure
MySQL高級篇第一章(linux下安裝MySQL)【下】
JS to achieve the effect of text marquee
I/O 虚拟化技术 — UIO Framework
DETR3D 多2d图片3D检测框架
ABP framework
Uni app swiper rotation chart (full screen / card)
Is the waiting insurance record a waiting insurance evaluation? What is the relationship between the two?
Some mobile phones open USB debugging, and the solution to installation failure
Introduction of mybatis invalid
MySQL advanced Chapter 1 (installing MySQL under Linux) [2]
等保备案是等保测评吗?两者是什么关系?
[appium stepping pit] io appium. uiautomator2. common. exceptions. InvalidArgumentException: ‘capabilities‘ are mand
Uni app Baidu cloud realizes OCR ID card recognition
Quanergy欢迎Lori Sundberg出任首席人力资源官
Evaluation - analytic hierarchy process
XML parsing bean tool class
Sqlitestudio download address
力扣79单词搜索