Answers for "graph a line from dataframe values over a bar plot in python"

0

graph a line from dataframe values over a bar plot in python

df = pd.DataFrame({'year':[2001,2002,2003,2004,2005], 'value':[100,200,300,400,500]})
df['value1']= df['value']*0.4
df['value2'] = df['value']*0.6
df['year'] = df['year'].astype("string") # Let them be strings!
fig, ax = plt.subplots(figsize = (15,8))
df.plot(x = ['year'], y = ['value'], kind = 'line', ax = ax)
df.plot(x = ['year'], y= ['value1','value2'], kind = 'bar', ax = ax)
Posted by: Guest on March-06-2022

Code answers related to "graph a line from dataframe values over a bar plot in python"

Python Answers by Framework

Browse Popular Code Answers by Language