Python 具有多个图形的图形中的线型
我有一个如下所示的数据帧:Python 具有多个图形的图形中的线型,python,pandas,numpy,matplotlib,jupyter-notebook,Python,Pandas,Numpy,Matplotlib,Jupyter Notebook,我有一个如下所示的数据帧: a b c d e 2020-06-01 90955 2814823.0 5422676.0 1135754.0 3716537.0 2020-07-01 100498 3116529.0 5908477.0 1368607.0 3056651.0 2020-08-01 97441 3107987.0 5702994.0 13
a b c d e
2020-06-01 90955 2814823.0 5422676.0 1135754.0 3716537.0
2020-07-01 100498 3116529.0 5908477.0 1368607.0 3056651.0
2020-08-01 97441 3107987.0 5702994.0 1340020.0 3235909.0
2020-09-01 95916 3073612.0 5803623.0 1275557.0 2951018.0
2020-10-01 94436 3090192.0 5943429.0 1262183.0 2882972.0
2020-11-01 92148 2826019.0 5495001.0 1214844.0 2567679.0
ax = df.plot(figsize=(8,3))
ax.autoscale(axis='x',tight=True)
ax.legend(loc=3, bbox_to_anchor=(1.0,0.1));
然后,我像这样绘制数据帧:
a b c d e
2020-06-01 90955 2814823.0 5422676.0 1135754.0 3716537.0
2020-07-01 100498 3116529.0 5908477.0 1368607.0 3056651.0
2020-08-01 97441 3107987.0 5702994.0 1340020.0 3235909.0
2020-09-01 95916 3073612.0 5803623.0 1275557.0 2951018.0
2020-10-01 94436 3090192.0 5943429.0 1262183.0 2882972.0
2020-11-01 92148 2826019.0 5495001.0 1214844.0 2567679.0
ax = df.plot(figsize=(8,3))
ax.autoscale(axis='x',tight=True)
ax.legend(loc=3, bbox_to_anchor=(1.0,0.1));
每列都有不同的颜色,图例在图形的侧面(我想要)
如何更改每列的行类型?
例如,一条是直线,另一条是虚线?将列表作为
将熊猫作为pd导入
从matplotlib导入pyplot作为plt
df=pd.DataFrame({'a':{'2020-06-01':90955,'2020-07-01':100498,
'2020-08-01': 97441, '2020-09-01': 95916,
'2020-10-01': 94436, '2020-11-01': 92148},
‘b’:{'2020-06-01':2814823.0,'2020-07-01':3116529.0,
'2020-08-01': 3107987.0, '2020-09-01': 3073612.0,
'2020-10-01': 3090192.0, '2020-11-01': 2826019.0},
c:{'2020-06-01':5422676.0,'2020-07-01':5908477.0,
'2020-08-01': 5702994.0, '2020-09-01': 5803623.0,
'2020-10-01': 5943429.0, '2020-11-01': 5495001.0},
‘d’:{'2020-06-01':1135754.0,'2020-07-01':1368607.0,
'2020-08-01': 1340020.0, '2020-09-01': 1275557.0,
'2020-10-01': 1262183.0, '2020-11-01': 1214844.0},
‘e’:{'2020-06-01':3716537.0,'2020-07-01':3056651.0,
'2020-08-01': 3235909.0, '2020-09-01': 2951018.0,
'2020-10-01': 2882972.0, '2020-11-01': 2567679.0}})
行_样式=['bs-'、'^'、'--'、'o-']
ax=df.plot(figsize=(8,3),style=line\u样式)
ax.自动缩放(轴=x',紧密=真)
ax.图例(loc=3,bbox_至_锚=(1.0,0.1))
plt.show()