当前位置:网站首页>【头歌】重生之我在py入门实训中(12):Matplotlib接口和常用图形
【头歌】重生之我在py入门实训中(12):Matplotlib接口和常用图形
2022-07-27 05:19:00 【垮起个老脸】
创作不易,参考之前,点个赞,收藏,关注一下不过分吧,家人们
第1关:画图接口
任务描述
本关任务:掌握matplotlib的基本使用技巧,并能简单使用matplotlib进行可视化。-
------------------------------------
编程要求
在右侧编辑器Begin-End补充代码,对传入的x,y两个数组做折线图,x对应x轴,y对应y轴。并保存到Task1/image1/T2.png,具体要求如下:
折线图的
figsize为(10, 10);文件名为
Task1/image1/T2.png。# ********** Begin *********# fig = plt.figure(figsize=(10,10)) plt.savefig("Task1/image1/T2.png") plt.show() # ********** End **********#
第2关:线形图
任务描述
本关任务:学习掌握matplotlib的第一个图形线形图,并能够使用线形常用配置。
----------------------------------
编程要求
在右侧编辑器Begin-End补充代码,根据输入数据input_data,input_data1绘制两条折线图。依次为两组数据设置颜色样式为--g,:r;设置图例为L1,L2,具体要求如下:
折线图的
figsize为(10, 10);图形保存到
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 *********#
第3关:散点图
任务描述
本关任务:编写一个包含三组不同样式的散点图。
----------------------------------------
编程要求
在右侧编辑器补充代码,根据输入的三组数据绘制三组不同参数的散点图,具体要求如下:
第一组数据参数设置标记大小为
area,透明度为0.5;第二组数据参数设置标记大小为
area,标记颜色为绿色,透明度为0.6;第三组数据参数设置标记大小为
area,标记颜色为area,标记样式为v,透明度为0.7;图形的
figsize为(10, 10);图形保存到
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 *********#第4关:直方图
任务描述
本关任务:绘制一个包含直方图与线形图的图形。
---------------------------------------------------------------------
编程要求
在右侧编辑器Begin-End处补充代码,根据输入数据将直方图与线形图绘制在同一面板中,并设置直方图为红色,线形图为蓝色,具体要求如下:
图形的
figsize为(10, 10);文件名为
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 *********#第5关:饼图
任务描述
本关任务:绘制一个饼图。
-----------------------------------------------
编程要求
在右侧编辑器Begin-End处补充代码,根据输入数据labels、quants绘制饼图,并设置第二块突出0.1和显示各块的百分比,具体要求如下:
输入数据
labels、quants为长度为10的列表图形的
figsize为(6, 6)文件名为
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 *********#注:内容只做参考和分享,未经允许不可传播,侵权立删
边栏推荐
- Speech and Language Processing (3rd ed. draft) Chapter 2 ——正则表达式,文本归一化,编辑距离 阅读笔记
- Day 9. Graduate survey: A love–hurt relationship
- Day14. Using interpretable machine learning method to distinguish intestinal tuberculosis and Crohn's disease
- 2. Simple regression problem
- 图像超分辨率评价指标
- Digital image processing -- Chapter 9 morphological image processing
- GBASE 8C——SQL参考6 sql语法(11)
- 3. Classification problems - initial experience of handwritten digit recognition
- Day14. 用可解释机器学习方法鉴别肠结核和克罗恩病
- 古老的艺术-用好长尾关键词
猜你喜欢

6. Dimension transformation and broadcasting

DSGAN退化网络

【12】理解电路:从电报机到门电路,我们如何做到“千里传信”?

导数、偏导数以及梯度

Speech and Language Processing (3rd ed. draft) Chapter 2 ——正则表达式,文本归一化,编辑距离 阅读笔记

【Arduino】重生之Arduino 学僧(1)

数字图像处理第四章——频率域滤波

【Unity URP】代码获取当前URP配置UniversalRendererData,并动态添加RendererFeature

贪心高性能神经网络与AI芯片应用研修

【MVC架构】MVC模型
随机推荐
GBASE 8C——SQL参考4 字符集支持
常用adb命令汇总 性能优化
Day 15. Deep learning radiomics can predict axillary lymphnode status in early-stage breast cancer
一张照片攻破人脸识别系统:能点头摇头张嘴,网友
Day 4.Social Data Sentiment Analysis: Detection of Adolescent Depression Signals
[MySQL learning] 8
Andorid detects GPU rendering speed and over rendering
Global evidence of expressed sentimental alterations during the covid-19 pandemics
Day 11. Evidence for a mental health crisis in graduate education
关于pytorch转onnx经常出现的问题
DSGAN退化网络
小技巧-彻底删除U盘中的文件
【并发编程系列9】阻塞队列之PriorityBlockingQueue,DelayQueue原理分析
为什么交叉熵损失可以用于刻画损失
Gbase 8C - SQL reference 6 SQL syntax (1)
Day 11. Evidence for a mental health crisis in graduate education
Activity之应用进程创建流程简析
A photo breaks through the face recognition system: you can nod your head and open your mouth, netizens
Day 9. Graduate survey: A love–hurt relationship
Day 6. Analysis of the energy transmission process of network public opinion in major medical injury events * -- Taking the "Wei Zexi incident" as an example