Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用matplotlib绘制栅格时没有垂直线_Python_Pandas_Matplotlib - Fatal编程技术网

Python 使用matplotlib绘制栅格时没有垂直线

Python 使用matplotlib绘制栅格时没有垂直线,python,pandas,matplotlib,Python,Pandas,Matplotlib,当我从数据框中绘制pyploy.subplot时,我没有垂直线。 数据帧索引看起来: df_month.index DatetimeIndex(['2016-01-31', '2016-02-29', '2016-03-31', '2016-04-30', '2016-05-31', '2016-06-30', '2016-07-31', '2016-08-31', '2016-09-30', '2016-10-31', '2016-1

当我从数据框中绘制pyploy.subplot时,我没有垂直线。 数据帧索引看起来:

df_month.index
DatetimeIndex(['2016-01-31', '2016-02-29', '2016-03-31', '2016-04-30',
               '2016-05-31', '2016-06-30', '2016-07-31', '2016-08-31',
               '2016-09-30', '2016-10-31', '2016-11-30', '2016-12-31'],
              dtype='datetime64[ns]', freq='M')
我需要每行的垂直线。 实际上,我的数字看起来(当我增加时间间隔时,每个一月的指数都有一条垂直线):

这是一个代码:

seaborn.set()
fig, axis = plt.subplots(nrows=6, sharex=True)

df_month.sum(axis=1).plot(ax=axis[0], marker = '.')

axis[0].set_title('Sum of costs')

for index, category in enumerate(df_month.columns.unique(), start=1):
    df_month[category].sum(axis=1).plot(ax=axis[index], marker = '.')
    axis[index].set_title(category)

plt.show()

您必须使用以下命令分别为每个轴对象
ax
绘制小刻度和大刻度的网格线:

ax.grid(b='on', which='major', color='k', linewidth=.5)
ax.grid(b='on', which='minor', color='k', linewidth=.25)
您必须在子地块的所有轴对象上循环实现此代码

在此处查找更多信息:

添加plt.axvline(i,ymin=0,ymax=1),其中我必须由月份替换