2011-03-01 34 views
34

展望垂直空間繪製圖形之間添加到允許的X軸標籤顯示:極品X軸標籤的次要情節之間添加空間,也許去掉軸缺口的標籤

每個圖形都需要有空間顯示當天,現在最後的2張圖是唯一的顯示,因爲圖是重疊的。

也很好奇,如果我實際上可以刪除X軸上的標記星號爲星期四/星期五以上的圖表的缺口標籤,即底部X軸是唯一顯示的圖標。 Y軸相同,但僅顯示左側的圖表。

*很抱歉,我無法發佈圖片以顯示此信息,因爲我沒有足夠的代表。

代碼片段:

import mathlib.pyplot as pyplot 
fig = pyplot.figure() 
ax1 = fig.add_subplot(4,2,1) 
ax1.set_yscale('log') 
ax2 = fig.add_subplot(4,2,2, sharex=ax1, sharey=ax1) 
ax3 = fig.add_subplot(4,2,3, sharex=ax2, sharey=ax2) 
ax4 = fig.add_subplot(4,2,4, sharex=ax3, sharey=ax3) 
ax5 = fig.add_subplot(4,2,5, sharex=ax4, sharey=ax4) 
ax6 = fig.add_subplot(4,2,6, sharex=ax5, sharey=ax5) 
ax7 = fig.add_subplot(4,2,7, sharex=ax6, sharey=ax6) 
ax1.plot(no_dict["Saturday"],'k.-',label='Saturday') 
ax1.set_xlabel('Saturday') 
ax1.axis([0,24,0,10000]) 
pyplot.suptitle('Title') 
pyplot.xlabel('Hour in 24 Hour Format') 
ax2.plot(no_dict["Sunday"],'b.-',label='Sunday') 
ax2.set_xlabel('Sunday') 
... 

too crowded

+0

請嘗試發佈可運行代碼。它可以節省時間讓一個人(你)清理代碼,而不是讓每個人都試圖回答它。即'輸入mathlib'和一些示例數據,而不是鏈接到一個不存在的字典。 – Paul 2011-03-01 19:17:15

+0

啊,好點,當我發佈這個消息的時候,我正在休息午餐,否則我會在你回答之前讓它實際運行。 – 2011-03-01 19:48:16

回答

76

使用subplots_adjust。在你的情況,這看起來不錯:

fig.subplots_adjust(hspace=.5) 

去掉勾選標籤做到這一點:

ax1.set_xticklabels([]) 

類似的yticklabels。但是,您不能與具有刻度標籤的圖表共享x軸。

enter image description here

+0

請注意,圖形窗口有一個帶有按鈕的工具欄,它允許人們以交互方式調整這些設置(如'hspace')。 – 2017-08-03 08:10:51