~ubuntu-branches/ubuntu/trusty/matplotlib/trusty-proposed

« back to all changes in this revision

Viewing changes to doc/pyplots/compound_path_demo.py

  • Committer: Package Import Robot
  • Author(s): Sandro Tosi
  • Date: 2011-01-25 18:17:56 UTC
  • mfrom: (0.1.1) (1.2.4) (9.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20110125181756-r2ckh9qfadms2k3x
Tags: 1.0.1-1
* New upstream release; Closes: #606116
* debian/patches/{10_build_fix.patch, 20_matplotlibrc_path_search_fix.patch}
  - updated to new upstream code
* debian/patches/30_doc_pass_dpi.patch
  - removed, merged upstream
* debian/rules
  - don't compress objects.inv; thanks to Michael Fladischer for the report;
    Closes: #608760
* debian/rules, debian/patches/30_disable_sample_downloads.patch
  - bypass examples data download from internet, but use local copy instead
* debian/python-matplotlib-data.install
  - install examples sample data
* debian/control
  - bump Standards-Version: to 3.9.1 (no changes needed)
  - removed DM-U-A flag, no more needed
  - added python-xlwt to b-d, needed to build doc examples
  - Benjamin Drung removed himself from the Uploaders list
* debian/copyright
  - updated debian packaging copyright
* debian/patches/40_bts608939_draw_markers_description.patch
  - fix a glitch (missing reference to documentation page) in draw_markers()
    description; thanks to Jakub Wilk for report and patch; Closes: #608939
* debian/patches/50_bts608942_spaces_in_param_args.patch
  - don't separate param and its argument with a space, new sphinx consider
    the first argument as the type; thanks to Jakub Wilk for the report;
    Closes: #608942
* debian/patches/60_doc_output_format.patch
  - obtain the documentation output format even if the value is a unicode (as
    returned by recent sphinx); thanks to Jakub Wilk for the tip on IRC

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import numpy as np
 
2
 
 
3
import matplotlib.pyplot as plt
 
4
import matplotlib.patches as patches
 
5
import matplotlib.path as path
 
6
 
 
7
fig = plt.figure()
 
8
ax = fig.add_subplot(111)
 
9
 
 
10
# histogram our data with numpy
 
11
data = np.random.randn(1000)
 
12
n, bins = np.histogram(data, 100)
 
13
 
 
14
# get the corners of the rectangles for the histogram
 
15
left = np.array(bins[:-1])
 
16
right = np.array(bins[1:])
 
17
bottom = np.zeros(len(left))
 
18
top = bottom + n
 
19
nrects = len(left)
 
20
 
 
21
nverts = nrects*(1+3+1)
 
22
verts = np.zeros((nverts, 2))
 
23
codes = np.ones(nverts, int) * path.Path.LINETO
 
24
codes[0::5] = path.Path.MOVETO
 
25
codes[4::5] = path.Path.CLOSEPOLY
 
26
verts[0::5,0] = left
 
27
verts[0::5,1] = bottom
 
28
verts[1::5,0] = left
 
29
verts[1::5,1] = top
 
30
verts[2::5,0] = right
 
31
verts[2::5,1] = top
 
32
verts[3::5,0] = right
 
33
verts[3::5,1] = bottom
 
34
 
 
35
barpath = path.Path(verts, codes)
 
36
patch = patches.PathPatch(barpath, facecolor='green', edgecolor='yellow', alpha=0.5)
 
37
ax.add_patch(patch)
 
38
 
 
39
ax.set_xlim(left[0], right[-1])
 
40
ax.set_ylim(bottom.min(), top.max())
 
41
 
 
42
plt.show()