我正在尝试使用 Dataframe 绘制折线图。执行此操作后,我在图形上看到单行数据的三个数据点。
fig = plt.figure(figsize=(8, 4.6), dpi=100)
ax = fig.add_subplot(111)
ax.plot(df[column], df['Value'])
当我使用 DataFrame 的条形图时,我可以正确地看到绘图。
df.plot(x=column, ax=ax, kind='bar')
如何纠正这个问题?
请您参考如下方法:
删除“GNRL_Scenario”列中的重复值并绘制图形。
fig = plt.figure(figsize=(8, 4.6), dpi=100)
ax = fig.add_subplot(111)
df = df.drop_duplicates(df[column]) #for dropping duplicate values in this column
ax.plot(df[column], df['Value'])
