2015-03-31 206 views
0

我有一個對數輪廓圖,我需要顯示次要刻度。所以我用刪除對數圖中的特定x軸刻度標籤,matplotlib

ax.xaxis.set_minor_formatter(fmt("%.1f")) 
ax.yaxis.set_minor_formatter(fmt("%.1f")) 

其中fmtfrom matplotlib.ticker import FormatStrFormatter as fmt

這工作得很好,給我所有的次要刻度線。但是,正如您從附加圖片中可以看到的那樣,x軸的刻度尤其是7.0,8.0 and 9.0是與重疊的刻度,並且我想明確地只刪除它們,但具有其他小刻度。

這可能嗎?我無法找到刪除特定小勾號的代碼。

enter image description here

+0

@:檢查這個答案http://stackoverflow.com/questions/13576805/matplotlib-hiding-specific-ticks-on-x-axis – George 2015-03-31 13:24:49

+0

@George我實際上找到了一個更簡單的解決方案[這裏](HTTP:///stackoverflow.com/questions/6567724/matplotlib-so-log-axis-only-has-minor-tick-mark-labels-at-specified-points-also)後,我發佈了問題。 – ThePredator 2015-03-31 13:27:01

回答

1

立即張貼的問題後,我發現了一個簡單的解決方案。

它是使用ax.xaxis.set_minor_locator(plt.FixedLocator([2,3,4,5]))

名單內FixedLocator做這項工作。