我试图以此为依据来制作意大利面条图:https://python-graph-gallery.com/123-highlight-a-line-in-line-plot/
运行但破坏了情节
剧情进行得很好,只是补语不起作用
#This works fine
plt.style.use('seaborn-darkgrid')
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
for column in MKT_DF_PVT.drop('Year', axis=1):
plt.plot(MKT_DF_PVT['Year'], MKT_DF_PVT[column], marker='', linewidth=4, alpha=0.7)
plt.xlim(2000,2016)
#This part doesn' work
num=0
for i in MKT_DF_PVT.values[len(MKT_DF_PVT.index)-1][1:]:
num+=1
name=list(MKT_DF_PVT)[num]
plt.text(10.2, i, name, horizontalalignment='left', size='small', color='grey')
也许与变量类型有关?
print(MKT_DF_PVT.info())
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 15 entries, 0 to 14
Data columns (total 8 columns):
Year 15 non-null int64
13.0 15 non-null float64
14.0 15 non-null float64
15.0 15 non-null float64
15.3 15 non-null float64
15.5 15 non-null float64
16.0 15 non-null float64
16.1 12 non-null float64
dtypes: float64(7), int64(1)
memory usage: 1.0 KB
None