当前位置:网站首页>Matplotlip basic drawing learning of data analysis - 01
Matplotlip basic drawing learning of data analysis - 01
2022-06-12 00:13:00 【Little apes are not bald】
Yes matplotlip The understanding of the :
matplotlip yes Pychon An open source project in , by Pychon Provides a powerful data mapping package .
Let's draw a legend to learn matplotlip Basic knowledge related to
example : draw 10—12 Point temperature over time
# list a Express 10 Point to 12 The temperature of every minute of the hour , How to draw a broken line statistical chart to observe the temperature change every minute
# a = [random.randint(20,35) for i in range(120)]
# random.randint( Parameter one , Parameter two ), Parameters 1、 Parameters 2 It has to be an integer
# This function returns an argument 1 And parameters 2 Any integer between , Closed interval
# Pilot Kit ,
from matplotlip import plot as plt
# Pass in x Axis y Axis data
x = range(0,120)
y = [random.randint(20,35) for i in range(120)]
# Draw , Pass in x,y data , call plot() function
plt.plot(x,y)
# Show the image
plt.show()
The drawn image is as follows , But we found some problems , Such as x Axis y No prompt for axis ,x The coordinate time format of the axis is not equal . Let's revise it

# list a Express 10 Point to 12 The temperature of every minute of the hour , How to draw a broken line statistical chart to observe the temperature change every minute
# a = [random.randint(20,35) for i in range(120)]
# random.randint( Parameter one , Parameter two ), Parameters 1、 Parameters 2 It has to be an integer
# This function returns an argument 1 And parameters 2 Any integer between , Closed interval
# Pilot Kit ,
import random
from matplotlib import font_manager
from matplotlib import pyplot as plt
# Pass in x Axis y Axis data
x = range(0, 120)
y = [random.randint(20, 35) for i in range(120)]
# Make some settings for the drawn image , Parameters figure(a,b) Is the size of the image ,dpi(a) Equivalent to the pixels of the image
plt.figure(figsize=(20, 8), dpi=88)
# Draw , Pass in x,y data , call plot() function
plt.plot(x, y)
# adjustment x Axis scale
# After converting to a list, perform the step size operation
_x = list(x)[::3]
# Here are the settings x Format of axis data
_xtick_lables = ["10 spot {} branch ".format(i) for i in range(60)]
_xtick_lables = ["11 spot {} branch ".format(i - 60) for i in range(60, 120)]
# The next step is to x Axis y The axes correspond one by one
# In addition, we set up a prompt message to x Axis y Shaft description
plt.xticks(_x[::3], _xtick_lables[::3], rotation=45, fontproperties=my_font)
my_font = font_manager.FontProperties(fname="msyh.ttc")
# because matplotlib Chinese fonts are not displayed by default
# to x Axis y Add description information to axis , We used xlable,ylabel
plt.xlabel(" Time ", fontproperties=my_font)
plt.ylabel(" temperature Company : Centigrade ", fontproperties=my_font)
# The following is the title of the image
plt.title("10 spot ——12 Line chart of temperature change with time ", fontproperties=my_font, size="larger")
# matplotlib Chinese will not be displayed by default , So we need to set it ourselves , Import fonts from your computer before : Setting the font format and syntax is fixed , In addition, there are other ways to display Chinese, which is relatively simple
# my_font = font_manager.FontProperties(fname="msyh.ttc")
# Show the image
plt.show()

explain plt.xticks(_x[::3], _xtick_lables[::3], rotation=45, fontproperties=my_font) In the parameter rotation=45
Set up x The inclination of the shaft
When importing fonts, both relative and absolute paths can be used :
边栏推荐
- Sorting out app startup process
- MySQL basic tutorial -- MySQL transaction and storage engine
- MySQL some simple commands
- Summary of DOM knowledge points
- Share an open source, free and powerful video player library
- Meet o & M (I) common questions for O & M interview
- Construction environnementale 2
- oracle使用Navicat工具导入导出数据
- win10系统pscs6如何卸载
- Class. Getresource() and class Getresourceasstream() method
猜你喜欢

Graph and graph traversal

二叉排序树

C language leetcode deleting duplicate items in an ordered array

(simple statistics) acwing 3404 Who are your potential friends

【juc学习之路第5天】引用原子类和属性修改器

点云库pcl从入门到精通学习记录 第八章

Point cloud library PCL from introduction to mastery learning records Chapter 8
![[flume] notes](/img/33/50f14b0267c5e502970cee0278aa71.jpg)
[flume] notes
![[signals and systems] (XXII) Laplace transform and complex frequency domain analysis - s-domain analysis](/img/35/a23646ac8501ac646cd44eeecd5b79.jpg)
[signals and systems] (XXII) Laplace transform and complex frequency domain analysis - s-domain analysis

组态王如何利用无线Host-Link通信模块远程采集PLC数据?
随机推荐
月份选择器禁用当月以后的数据 包含当月
Collation of common array functions
730.Count Different Palindromic Subsequences
win10文件夹状态红叉表示的是什么
Seven trends in test automation that need attention
Construction environnementale 2
Pass the command parameters for operating mongodb to Mongo in the shell
Two configurations of data tables in efcore
How to optimize plantuml flow diagram (sequence diagram)
Introduction and installation steps of sonarqube
Anaconda download package error: valueerror: check_ hostname requires server_ hostname
多年测试菜鸟对黑盒测试的理解
926. Flip String to Monotone Increasing
設計消息隊列存儲消息數據的 MySQL 錶格
Experiment four categories and objects
(interval DP | dfs+ memory) acwing 282 Stone merging
Design principle [Demeter's Law]
[signals and systems] (XXII) Laplace transform and complex frequency domain analysis - s-domain analysis
Understanding of black box testing by novices after years of testing
oracle使用Navicat工具导入导出数据