无法在木本笔记本中将matplotlib图形保存到jpeg(空白)

问题描述 投票:0回答:1

我无法将图形保存到jpeg(或任何其他)文件(空白)

x=list(df2['DAYTIME'])
z=list(df2['av100002 - temp Wywiew'])
x3= x[::75]


fig1 = plt.figure()
axes1 = fig1.add_axes([0,30,3.5,1.4])
axes1.set_title('Nawiew')


axes1.plot(x,z, lw=3)

axes1.set_xticks(x3)  

plt.xticks(x3, rotation=60)
fig1.savefig('xx.png', dpi=200)
python matplotlib plot save figure
1个回答
0
投票

您的轴位置错误,使轴偏离图形。

尝试使用axes1 = fig1.add_subplot()进行快速修复,其中creates an axes centered in the figure space

如果要使用add_axes()手动放置轴,则the coordinates are given in figure fractions。坐标为[left,bottom,width,height],其中0表示图形的左/下边缘,1表示图形的右/上边缘。

默认情况下,fig.add_subplot()等同于fig.add_axes([0.125, 0.11, 0.9, 0.88])

© www.soinside.com 2019 - 2024. All rights reserved.