Skip to content

Instantly share code, notes, and snippets.

@macleginn
Created November 21, 2019 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macleginn/184279938bfa09eb8320c3c6b8b5d359 to your computer and use it in GitHub Desktop.
Save macleginn/184279938bfa09eb8320c3c6b8b5d359 to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
N = 5
menMeans = (20, 35, 30, 35, 27)
womenMeans = (25, 32, 34, 20, 25)
menStd = (2, 3, 4, 1, 2)
womenStd = (3, 5, 2, 3, 3)
ind = np.arange(N) # the x locations for the groups
width = 0.35 # the width of the bars: can also be len(x) sequence
fig = plt.figure(figsize=(16,10))
p1 = plt.bar(ind, menMeans, width, yerr=menStd)
p2 = plt.bar(ind, womenMeans, width,
bottom=menMeans, yerr=womenStd)
plt.ylabel('Scores')
plt.title('Scores by group and gender')
plt.xticks(ind, ('G1', 'G2', 'G3', 'G4', 'G5'))
plt.yticks(np.arange(0, 81, 10))
plt.legend((p1[0], p2[0]), ('Men', 'Women'))
fig.savefig('fig1.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment