matplotlib轴上的箱数(majorticks数量)

时间:2016-01-21 02:47:23

标签: python matplotlib plot

我在一个图中有6个轴。每个轴的限制是不同的。在每个轴上我给出了命令:

'unique'               => 'The :attribute has already been tak
'url'                  => 'The :attribute format is invalid.',

......                                                               
'good_email'       => 'Sorry :attribute must end with "@gmail.com"',   
......

但是当我绘制这个时,我得到了:

enter image description here

我想在每个轴的x轴上获得9个标签,每个轴的y轴上有7个标签。我怎样才能做到这一点?非常感谢。

1 个答案:

答案 0 :(得分:0)

from matplotlib.ticker import MaxNLocator
import matplotlib.pyplot as plt


fig, (ax1, ax2, ax3, ax4, ax5, ax6) = plt.subplots(nrows=2, ncols=3)
# add plot code here
ax1.xaxis.set_major_locator(MaxNLocator(nbins=9))
ax1.yaxis.set_major_locator(MaxNLocator(nbins=7))
#repeat for other axes