当前位置:网站首页>Matplotlib drawing core principles explain (more detailed)
Matplotlib drawing core principles explain (more detailed)
2022-08-03 00:38:00 【51CTO】
1、核心原理讲解
使用matplotlibThe principle of drawing,主要就是理解figure(画布)、axes(坐标系)、axis(坐标轴)三者之间的关系.
Zhang SAN's sketchpad
matplotlib绘图
2、matplotlib库的安装与导入
1)安装
2)导入相关库
Now you don't need to pay attention to what is the exact meaning of the following code,There is a subjective impression can.I will be in a future article,Introduce you don't know which parameters one by one to you.
结果如下:
3、创建figure(画布)的两种方式
1)Draw a simple line chart
结果如下:
结果分析:
在前面的叙述中,我们已经说过,想要使用matplotlib绘图,Must first create afigure(画布)对象,然后还要有axes(坐标系).But watch the code,我们并没有创建figure对象,So how can draw?
对于上述疑问,Then we will be creatingfigure(画布)的两种方式.
2)创建figure(画布)的两种方式
- 隐式创建
- 显示创建
① 隐式创建figure对象
当第一次执行plt.xxx()The drawing code,系统会去判断是否已经有了figure对象,如果没有,系统会自动创建一个figure对象,并且在这个figure之上,自动创建一个axes坐标系(注意:默认创建一个figure对象,一个axes坐标系).
也就是说,如果我们不设置figure对象,那么一个figure对象上,只能有一个axes坐标系,That we can only draw a shape.
② 隐式创建figureThe problems existing in the object
优势:If we can only draw a small graphics,那么直接使用plt.xxx()的方式,会自动帮我们创建一个figure对象和一个axes坐标系,This graphics eventually is drawn in thisaxesCoordinate system of.
劣势:If we want to be in afigure对象上,绘制多个图形,So we must get eachaxes对象,And then call each positionaxes对象,Can be in the position of each corresponding coordinate system on,进行绘图,如下图所示.注意:如果figureObject is created by default,So we simply can't getaxes对象.因此,We need to show to createfigure对象.
③ 显示创建figure对象:Future articles will be detailed layout Settings
如图所示:
举例说明:
结果如下:
4、The complete drawing steps
① 导库
② 创建figure画布对象
③ 根据figureObject to layout Settings
④ 获取对应位置的axes坐标系对象
⑤ 调用axes对象,进行对应位置的图形绘制
⑥ 显示图形
5、绘图技巧(细节设置)
通过对matplotlibThe principle of drawing,有所了解之后,We need to learn is commonmatplotlib绘图技巧,Common drawing techniques shown above,These drawing skills can be a good help us draw more beautiful、More intuitive graphics.下一节,I will tellmatplotlib绘图技巧(千万不要错过).
边栏推荐
- Sentinel vs Hystrix 限流对比,到底怎么选?
- golang 刷leetcode:祖玛游戏
- wallys/new product/WiFi6 MiniPCIe Module 2T2R 2×2.4GHz 2x5GHz MT7915 MT7975
- Learn more TypeScript 】 【 TypeScript modular
- 我用这一招让团队的开发效率提升了 100%!
- Abstract Factory Pattern
- JumpServer开源堡垒机完成龙芯架构兼容性认证
- 【干货】分库分表最佳实践
- win10安全中心设置不扫描某个文件夹的方法
- Swin Transformer 论文精读,并解析其模型结构
猜你喜欢
【TypeScript】深入学习TypeScript模块化
博客主题美化第二弹
【使用pyside2遇到的问题】This application failed to start because no Qt platform plugin could be initialized.
行业 SaaS 微服务稳定性保障实战
If the watermark according to how to realize the function
Interviewer: can you talk about optimistic locking and pessimistic locks
H5网页播放器EasyPlayer.js播放器界面的加载效果无法消失是什么原因?
win10桌面图标全部变成白色的怎么办
# 医院管理系统完整项目代码以及数据库建表语句分享
你我都会遇到的需求:如何导出MySQL中的数据~ 简单!实用!
随机推荐
牛客刷题:手动实现数组filter方法
主成分分析(PCA)
如何抓住NFT、元|宇|宙新趋势?
golang刷leetcode: 小于等于 K 的最长二进制子序列
我用这一招让团队的开发效率提升了 100%!
YAML文件格式
golang刷leetcode:统计区间中的整数数目
[TypeScript] Deep Learning of TypeScript Classes (Part 1)
软件测试到底自学还是报班?
无线振弦采集仪远程修改参数的方式
面试了个985毕业的,回答“性能调优”题时表情令我毕生难忘
Teach you how to kill if else
How does Redis easily achieve system instant kill?
万物智联时代,悄然走入生活
golang刷leetcode:我能赢吗
行业 SaaS 微服务稳定性保障实战
win10安全中心设置不扫描某个文件夹的方法
管理工具|宝藏书签收藏管理工具
什么是幂等
【STM32学习2】存储器相关概念与操作