8
我使用autofmt_xdate
以可讀方式繪製長x軸標籤。問題是,當我想要組合不同的子圖時,其他子圖的x軸標籤消失,對於下圖中最左側的子圖(兩行高),我不理解。有沒有辦法阻止autofmt_xdate
熄滅其他x軸標籤?或者還有另一種旋轉標籤的方法嗎?正如你所看到的,我也嘗試了xticks
和「旋轉」,但結果並不令人滿意,因爲標籤圍繞其中心旋轉,導致亂標籤。產生以下情節autofmt_xdate刪除所有子圖的x軸標籤
腳本:
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()