我使用autofmt_xdate
以可读的方式绘制长x轴标签。问题是,当我想组合不同的子块时,其他子块的x轴标记消失了,我不喜欢下图中最左边的子块(两行高)。有没有办法防止autofmt_xdate
淬火其他x轴标签?或者有其他方法来旋转标签吗?正如你所看到的,我也尝试了xticks
和“旋转”,但结果并不令人满意,因为标签围绕其中心旋转,这导致标签混乱。
生成以下绘图的脚本:
from matplotlib import pyplot as plt
from numpy import arange
import numpy
from matplotlib import rc
rc("figure",figsize=(15,10))
#rc('figure.subplot',bottom=0.1,hspace=0.1)
rc("legend",fontsize=16)
fig = plt.figure()
Test_Data = numpy.random.normal(size=20)
fig = plt.figure()
Dimension = (2,3)
plt.subplot2grid(Dimension, (0,0),rowspan=2)
plt.plot(Test_Data)
plt.subplot2grid(Dimension, (0,1),colspan=2)
for i,j in zip(Test_Data,arange(len(Test_Data))):
plt.bar(i,j)
plt.legend(arange(len(Test_Data)))
plt.subplot2grid(Dimension, (1,1),colspan=2)
xticks = [r"%s (%i)" % (a,b) for a,b in zip(Test_Data,Test_Data)]
plt.xticks(arange(len(Test_Data)),xticks)
fig.autofmt_xdate()
plt.ylabel(r'$Some Latex Formula/Divided by some Latex Formula$',fontsize=14)
plt.plot(Test_Data)
#plt.setp(plt.xticks()[1],rotation=30)
plt.tight_layout()
#plt.show()
这实际上是} 方法的文档中:
autofmt_xdate
方法的一个特性。从^{如果只想旋转右下方子批次的xticklabels,请使用
这会将ticklebels旋转30度并将其右对齐(与使用
autofmt_xdate
时的结果相同),保留其他两个子块不变。相关问题 更多 >
编程相关推荐