8000 Scipy2013 Sprint: Cleaning examples of api example by gabraganca · Pull Request #2181 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Scipy2013 Sprint: Cleaning examples of api example #2181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Clen bar plot demo
  • Loading branch information
gabraganca committed Jun 29, 2013
commit b0f85e7373d7c580cd1e6e8492abd1f3a726a0e7
40 changes: 7 additions & 33 deletions examples/api/barchart_demo.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,13 @@

#!/usr/bin/env python
# a bar plot with errorbars
import numpy as np
"""
Demo of multiple bar plots.
"""
import matplotlib.pyplot as plt

N = 5
menMeans = (20, 35, 30, 35, 27)
menStd = (2, 3, 4, 1, 2)

ind = np.arange(N) # the x locations for the groups
width = 0.35 # the width of the bars

fig, ax = plt.subplots()
rects1 = ax.bar(ind, menMeans, width, color='r', yerr=menStd)

womenMeans = (25, 32, 34, 20, 25)
womenStd = (3, 5, 2, 3, 3)
rects2 = ax.bar(ind+width, womenMeans, width, color='y', yerr=womenStd)

# add some text for labels, title and axes ticks
ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.set_xticks(ind+width)
ax.set_xticklabels( ('G1', 'G2', 'G3', 'G4', 'G5') )

ax.legend( (rects1[0], rects2[0]), ('Men', 'Women') )
values = (20, 35, 30, 35, 27)
pos = (0, 1, 2, 3, 4)

def autolabel(rects):
# attach some text labels
for rect in rects:
height = rect.get_height()
ax.text(rect.get_x()+rect.get_width()/2., 1.05*height, '%d'%int(height),
ha='center', va='bottom')
plt.bar(left=pos, height=values, width=0.5, color='r')

autolabel(rects1)
autolabel(rects2)
plt.title('Example of bar plots')

plt.show()
0