当前位置:网站首页>matplotlib 画图 Tips
matplotlib 画图 Tips
2022-06-21 12:24:00 【Mark_Aussie】
显示图形后自动关闭:
使用 plt.show() 如果不手动关闭则程序会卡住;
实际中遇到过的问题:使用plt.show()后可以显示需要的图,如不使用则无法正确显示,但需要生产大量的图,不能手动关闭,可使用如下方法替代 plt.show()
plt.pause(0.01) # 显示秒数 plt.close()
通过多线程的方式自动关闭fig的方法(未能成功)
matplotlib画图时调用多线程关闭图形显示_晓东邪的博客-CSDN博客_matplotlib画完图后关闭
设置线条类型:
使用 plt.plot() 画直线图,可使用 linestyle 设置线条类型;“:”表示点线(绿),“--”代表虚线(蓝)

自定义属性:color(颜色)marker(标记的形状)linestyle(线条形状)linewidth(线条宽度)marksize(标记的大小)label(标签,用于图例)
marker:S --> 实心正方形 P --> 实心五角星 O --> 实心圆 * --> 星形 D --> 菱形
linestyle:- 实线 : 虚线 – 破折线 -. 画点线
figure:
创建一个全局绘图区域,facecolor=None 为无色背景
plt.figure(figsize=None, facecolor=None) # figsize(a,b)中的参数a是指绘图区宽度,b则是高度

显示中文及字体设置:

标注图中值大小:
plt.text(a,b,b) # 数据显示x轴对应位置、显示的位置高度(可以调整)、显示的数据值的大小
for a, b in zip(x, highest): # 使用for 循环依次次输出 zip()对应连接
plt.text(a, b + 2, b, ha=‘center’, va=‘bottom’)

参考:
https://www.csdn.net/tags/NtjaYgwsMTY2OTUtYmxvZwO0O0OO0O0O.html
python条形图和线形图的绘制,并显示数据_键盘敲烂工资过万的博客-CSDN博客_python条形图怎么显示数据
边栏推荐
- 愿山河无恙
- STM32开发之 VS Code + GDB下载调试
- [100 unity pit knowledge points] | unity controls the object to continuously point in a certain direction
- 3D Slicer导入标签与查看标签
- The difference between knowing and understanding
- Jenkins configures scheduled tasks through build periodically
- [100 unity pit knowledge points] | unity uses quaternion Angleaxis random one direction
- Methods commonly used in uniapp (part) - timestamp problem and rich text parsing image problem
- typescript localStorage 封装
- CPU、MPU、MCU、SoC、MCM介绍
猜你喜欢

Nine trends and priorities that CIOs need to focus on in 2022

These three young men are more ruthless than Ma Huateng and Zhang Yiming

搭建zabbix监控及邮件报警

STM32开发之 VS Code + gcc环境编译

STM32笔记之 PWM(脉宽调制)

Educoder Web练习题---文本层次语义元素

STM32 notes swj (jtag-dp and sw-dp)

配电室环境监控系统技术方案

Travel does not heal the soul

A recovery solution of system paralysis caused by upgrading glibc of VMware virtual machine
随机推荐
STM32开发之 VS Code + gcc环境编译
EasyUI-input取/赋值
Educoder Web练习题---对表单进行验证
6. 函数
Nine trends and priorities that CIOs need to focus on in 2022
Redis最大内存淘汰策略
RPC (remote procedure call protocol)
动手学数据分析 数据可视化
Jenkins configures scheduled tasks through build periodically
自定义view绘制折线图(支持缩放)
Construction scheme and installation position of intelligent auxiliary system in power distribution room
~~~~Configuration
2022年CIO需要关注的九个趋势和优先事项
3D Slicer将分割结果保存
Redis personal summary concise version
How does Huawei build a project centered project management system from 0 to 1?
[100 unity pit knowledge points] | unity uses quaternion Angleaxis random one direction
配電室環境監控系統技術方案
typescript localStorage 封装
Detailed instructions for channels