I'm trying to create a simple plot from my dataframe. I've provided a reproducible example of what I'm doing now. It creates the bar chart I'd like buit without the y error bars to show the SEM of each mean value. How do I get the SEM values to show as error bars?
df = pd.DataFrame([{'Measures' : 'Pre Var 1',
'Mean' : 2,
'SEM' : 1}])
df[['Measures', 'Mean']].plot(x='Measures', kind='bar', yerr=df['SEM'])
This is what my code currently produces
This is the desired graph
CodePudding user response:
try this :
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.bar(df['Measures'], df['Mean'], yerr=df['SEM'])