【发布时间】:2012-05-13 08:10:22
【问题描述】:
对于我喜欢使用的字体大小,我发现 5 个刻度是 matplotlib 中几乎每个轴上最令人愉悦的刻度数。我也喜欢修剪 沿 x 轴的最小刻度,以避免重叠刻度标签。因此,对于我制作的几乎每一个情节,我都发现自己使用以下代码。
from matplotlib import pyplot as plt
from matplotlib.ticker import MaxNLocator
plt.imshow( np.random.random(100,100) )
plt.gca().xaxis.set_major_locator( MaxNLocator(nbins = 7, prune = 'lower') )
plt.gca().yaxis.set_major_locator( MaxNLocator(nbins = 6) )
cbar = plt.colorbar()
cbar.locator = MaxNLocator( nbins = 6)
plt.show()
是否有我可以使用的 rc 设置,以便我的 x 轴、y 轴和颜色条的默认定位器默认为上面的 MaxNLocator,x 轴上有修剪选项?
【问题讨论】:
标签: python matplotlib