matplotlib使用记录
工作中需要使用python的matplotlib包作图,记录了一些需要注意的坑。
1.Linux服务器没有GUI的情况下使用matplotlib绘图
1 | |
必须添加在import matplotlib.pyplot之前
2.解决matplotlib中文乱码
1 | |
3.解决matplotlib保存图像是负号’-‘显示为方块的问题
1 | |
4. matplotlib保存图片时不截取图表内容
1 | |
bbox_inches=’tight’可控制所画图表被完整保存下来,而不被截取掉。
使用前
使用后
5.matplotlib控制图例位置
plt.legend(bbox_to_anchor=(0.9, 0.9), fontsize=”x-small”)
6.控制图像边缘留白量
plt.subplots_adjust(top=0.9, right=0.85)
matplotlib使用记录
https://www.920929.xyz/posts/6430b1d0.html