标签从图片中删除。您只能部分查看它们。 如何使标签完全显示?
pyplot.style.use('ggplot')
y = -30
x = 70
ax2 = pyplot.gca()
pyplot.plot(powerdemand, linewidth=2.0)
pyplot.plot(middle, linewidth=4.0)
ax2.set_xlabel('Time in s')
ax2.set_ylabel('Power consumption in MW')
pyplot.ylim(y,x)
# Place a legend to the right of this smaller figure.
pyplot.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc=4,
ncol=1, mode="expand", borderaxespad=0.)
for label in ax2.get_xticklabels()[::2]:
label.set_visible(False)
for label in ax2.get_yticklabels()[::2]:
label.set_visible(False)
pyplot.setp(ax2.get_yticklabels(), visible=True)
matplotlib.rcParams.update({'font.size': 23})
pyplot.savefig("/Users/user/Desktop/test.png")
答案 0 :(得分:-3)
保存无花果时尝试bbox_index
:
pyplot.savefig("/Users/user/Desktop/test.png",bbox_index='tight')