对matplotlib使用AXIS表示法允许我手动绘制2x2或3x3网格或任何大小的网格(如果我事先知道我想要的网格大小 . )

但是,如何自动确定需要的网格大小 . 就像您不知道要绘制的列中有多少个唯一值一样?

我认为必须有一种方法可以在循环中执行此操作,并根据列中唯一值的数量计算出这是图表需要的大小 .

Example

当我因某种原因绘制它时,它不会在x轴上显示month_name(如Jan,Feb,Marc等)

avg_all_account.plot(legend=False,subplots=True,x='month_date',figsize=(10,20))
plt.xlabel('month')
plt.ylabel('number of proposals')

然而,当我在图上绘制子图并指定x轴参数x ='month_name'时,月图名称显示在此处:

f = plt.figure()
f.set_figheight(8)
f.set_figwidth(8)
f.sharex=True
f.sharey=True

#graph1 = f.add_subplot(2,2,1)
avg_all_account.ix[0:,['month_date','number_open_proposals_all']].plot(ax=f.add_subplot(331),legend=False,subplots=True,x='month_date',y='number_open_proposals_all',title='open proposals')
plt.xlabel('month')
plt.ylabel('number of proposals')

因此,因为subplot方法工作并在x轴上显示month_name,并且我的x和y轴标签:我想知道如何在不先计算它的情况下计算出我需要多少个子图,然后写出每一行并且很难编码子情节位置?