当前位置:网站首页>[song] rebirth of me in py introductory training (12): Matplotlib interface and common graphics
[song] rebirth of me in py introductory training (12): Matplotlib interface and common graphics
2022-07-27 06:05:00 【Collapse an old face】
It's not easy to create , Before reference , Point a praise , Collection , You can't pay too much attention , Family
The first 1 Turn off : Drawing interface
Task description
Our mission : master matplotlib Basic tips for using , And can be used simply matplotlib Visualizing .-
------------------------------------
Programming requirements
On the right editor Begin-End Supplementary code , The incoming x,y Make a line chart with two arrays ,x Corresponding x Axis ,y Corresponding y Axis . And save to Task1/image1/T2.png, The specific requirements are as follows :
Line graph
figsizeby(10, 10);The file named
Task1/image1/T2.png.# ********** Begin *********# fig = plt.figure(figsize=(10,10)) plt.savefig("Task1/image1/T2.png") plt.show() # ********** End **********#
The first 2 Turn off : Linear chart
Task description
Our mission : Learn to master matplotlib The first graphic line graph of , And can use the commonly used linear configuration .
----------------------------------
Programming requirements
On the right editor Begin-End Supplementary code , According to the input data input_data,input_data1 Draw two line charts . Set the color style for the two groups of data in turn as --g,:r; Set legend to L1,L2, The specific requirements are as follows :
Line graph
figsizeby(10, 10);Save drawing to
Task2/img/T1.png.def student(input_data,input_data1): # ********* Begin *********# fig = plt.figure(figsize=(10,10)) plt.plot(input_data,'--g') plt.plot(input_data1,':r') plt.legend(['L1','L2']) plt.savefig("Task2/img/T1.png") plt.show() # ********* End *********#
The first 3 Turn off : Scatter plot
Task description
Our mission : Write a scatter chart with three different styles .
----------------------------------------
Programming requirements
Add code to the editor on the right , According to the three groups of input data, draw three groups of scatter diagrams with different parameters , The specific requirements are as follows :
The first set of data parameters sets the tag size to
area, Transparency is0.5;The second set of data parameters sets the tag size to
area, The marking color is green , Transparency is0.6;The third set of data parameters sets the tag size to
area, The marking color isarea, The tag style isv, Transparency is0.7;Graphic
figsizeby(10, 10);Save drawing to
Task3/img/T1.png.
:return: None
'''
# ********* Begin *********#
fig = plt.figure(figsize=(10,10))
plt.scatter(x,y,s = area, alpha = 0.5)
plt.scatter(x2,y2,s = area, c = 'g', alpha = 0.6)
plt.scatter(x3,y3,s = area, marker = 'v', alpha = 0.7)
plt.savefig("Task3/img/T1.png")
plt.show()
# ********* End *********#The first 4 Turn off : Histogram
Task description
Our mission : Draw a graph containing histogram and linear graph .
---------------------------------------------------------------------
Programming requirements
On the right editor Begin-End Add the code , According to the input data, the histogram and linear graph are drawn in the same panel , And set the histogram to red , The line graph is blue , The specific requirements are as follows :
Graphic
figsizeby(10, 10);The file named
Task4/img/T1.png.
:return: None
'''
# ********* Begin *********#
fig = plt.figure(figsize=(10,10))
plt.hist(data,facecolor="red")
plt.plot(x,y,color="blue")
plt.savefig("Task4/img/T1.png")
plt.show()
# ********* End *********#The first 5 Turn off : The pie chart
Task description
Our mission : Draw a pie chart .
-----------------------------------------------
Programming requirements
On the right editor Begin-End Add the code , According to the input data labels、quants Draw the pie chart , And set the second block to highlight 0.1 And display the percentage of each block , The specific requirements are as follows :
input data
labels、quantsFor a length of10A list ofGraphic
figsizeby(6, 6)The file named
Task5/img/T1.pngdef student(labels,quants): # ********* Begin *********# fig=plt.figure(figsize=(6,6)) sizes = quants plt.pie(sizes,labels=labels,explode=(0,0.1,0,0,0,0,0,0,0,0),autopct='%1.1f%%') plt.savefig("Task5/img/T1.png") plt.show() # ********* End *********#notes : The content is only for reference and sharing , Do not spread without permission , Tort made delete
边栏推荐
猜你喜欢

超强远程连接管理工具:Royal TSX

DSGAN退化网络

安装windows下的redis

15. GPU acceleration, Minist test practice and visdom visualization

Xmind 思维导图 2022 v12.0.3中文版更新了哪些内容?

pytorch使用data_prefetcher提升数据读取速度

Kaggle调用自定义模块方法

Essential tool for making video special effects: nuke 13

2. Simple regression problem

geonode geoserver win10 安装教程(亲测)
随机推荐
Unittest套件与运行器
Lightroom Classic 2022 v11.4中文版「最新资源」
【Arduino】重生之Arduino 学僧(1)
geonode geoserver win10 安装教程(亲测)
PS 2022 updated in June, what new functions have been added
Greedy high performance neural network and AI chip application research and training
Pix2Pix原理解析
[MySQL learning] 8
数字图像处理——第六章 彩色图像处理
Redis在windows下的idea连接不上问题
神经网络参数初始化
pytorch的多GPU训练的两种方式
pytorch转onnx相关问题
【头歌】重生之我在py入门实训中(9):异常处理
【头歌】重生之我在py入门实训中(8): 模块
个人开发者申请代码签名证书的签发流程
2. Simple regression problem
4. Tensor data type and creation tensor
韦东山 数码相框 项目学习(三)freetype的移植
【头歌】重生之我在py入门实训中(5):列表