当前位置:网站首页>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绘图技巧(千万不要错过).
边栏推荐
- 从零开始配置 vim(5)——本地设置与全局设置
- 我用这一招让团队的开发效率提升了 100%!
- 无线振弦采集仪远程修改参数的方式
- JumpServer open source bastion machine completes Loongson architecture compatibility certification
- 双轴晶体中的锥形折射
- Teach you how to kill if else
- wallys/new product/WiFi6 MiniPCIe Module 2T2R 2×2.4GHz 2x5GHz MT7915 MT7975
- YARN资源调度系统介绍
- 采用QT进行OpenGL开发(三)着色器编程
- 谷粒商城-day13-es和商品上架
猜你喜欢
随机推荐
@Transactional 事务调用与生效场景总结
采用QT进行OpenGL开发(三)着色器编程
js函数防抖和函数节流及其他使用场景
Learn more TypeScript 】 【 TypeScript modular
“百日行动”进行时:700余交通安全隐患被揪出
软件测试笔试题1(附答案)
从月薪10k到30k的必走之路:自动化测试
How many ways do you know the singleton pattern?
Intensive reading of the Swin Transformer paper and analysis of its model structure
【TypeScript】深入学习TypeScript类(上)
抽象工厂模式
golang 刷leetcode:Morris 遍历
golang刷leetcode:我能赢吗
I interviewed a 985 graduate, and I will never forget the expression when answering the "performance tuning" question
hi!Don't look at how to SAO gas dye-in-the-wood in MySQL?
微软SQL服务器被黑客入侵以窃取代理服务的带宽
# 医院管理系统完整项目代码以及数据库建表语句分享
How does Redis easily achieve system instant kill?
【干货】分库分表最佳实践
ML之PDP:基于titanic泰坦尼克是否获救二分类预测数据集利用PDP部分依赖图对RF随机森林和LightGBM模型实现可解释性案例