gpt4 book ai didi

python - Matplotlib 标签显示不全

转载 作者:行者123 更新时间:2023-12-05 08:13:00 26 4
gpt4 key购买 nike

enter image description here

标签从图片上切掉了。您只能部分查看它们。如何使标签完整显示?

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")

最佳答案

保存无花果时尝试bbox_index:

pyplot.savefig("/Users/user/Desktop/test.png",bbox_index='tight')

关于python - Matplotlib 标签显示不全,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30416238/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com