是否有 matplotlib.pyplot 函数来绘制两列图?
Is there a matplotlib.pyplot function to draw two columns plot?
我正在试验数据可视化。
我有以下数据框:
one = {'year' : [2010,2011,2012,2010],
'value' : [10,10,20,30],
'model' : ['one', 'one', 'one', 'two']}
df = pd.DataFrame(one)
df
我想绘制一条线来显示模型一的增加值。
我试过这个:
df.set_index('model').loc['one'].plot()
但它没有显示适当的情节,即 df.set_index('model').loc['one']
与 df['year']
有帮助吗?
IIUC:
尝试:
df.pivot('model','year','value').plot()
或
#import seaborn as sns
sns.relplot(kind='line',x='model',y='value',data=df,hue='year')
输出:
我正在试验数据可视化。
我有以下数据框:
one = {'year' : [2010,2011,2012,2010],
'value' : [10,10,20,30],
'model' : ['one', 'one', 'one', 'two']}
df = pd.DataFrame(one)
df
我想绘制一条线来显示模型一的增加值。 我试过这个:
df.set_index('model').loc['one'].plot()
但它没有显示适当的情节,即 df.set_index('model').loc['one']
与 df['year']
有帮助吗?
IIUC:
尝试:
df.pivot('model','year','value').plot()
或
#import seaborn as sns
sns.relplot(kind='line',x='model',y='value',data=df,hue='year')
输出: