【发布时间】:2017-10-18 15:32:02
【问题描述】:
我的 x 轴刻度标签(下图)正在从整体图中窃取宝贵的空间。我试图通过更改文本旋转来减小它的大小,但这并没有多大帮助,因为文本标签很长。
有没有更好的方法来减少 xticklabel 区域占用的空间?例如,我可以在栏内显示此文本吗?感谢您的支持。
我的图表设置代码是:
import matplotlib.pyplot as plt
import matplotlib
matplotlib.rcParams['font.sans-serif'] = "Century Gothic"
matplotlib.rcParams['font.family'] = "Century Gothic"
ax = df1.plot.bar(x = '', y = ['Events Today', 'Avg. Events Last 30 Days'], rot = 25, width=0.8 , linewidth=1, color=['midnightblue','darkorange'])
for item in ([ax.xaxis.label, ax.yaxis.label] +
ax.get_xticklabels() + ax.get_yticklabels()):
item.set_fontsize(15)
ax.legend(fontsize = 'x-large', loc='best')
plt.tight_layout()
ax.yaxis.grid(True, which='major', linestyle='-', linewidth=0.15)
ax.set_facecolor('#f2f2f2')
plt.show()
【问题讨论】:
-
问题的minimal reproducible example 怎么样?
-
?!提供描述、代码、打印..
-
你是在问我或任何愿意回答这个问题的人来自己产生一些
df1。鉴于您是在这里寻求帮助的人,这对您不太好。 -
我不是问你什么,如果你不想帮助就不要帮助。
-
您肯定需要添加一些示例数据。如果没有,我要做的就是将您链接到 matplotlib 开发版本的文档中的教程:matplotlib.org/devdocs/tutorials/intermediate/…
标签: python matplotlib plot axis-labels