2015-03-31 202 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做这项工作。