You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(115) |
Aug
(120) |
Sep
(137) |
Oct
(170) |
Nov
(461) |
Dec
(263) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(120) |
Feb
(74) |
Mar
(35) |
Apr
(74) |
May
(245) |
Jun
(356) |
Jul
(240) |
Aug
(115) |
Sep
(78) |
Oct
(225) |
Nov
(98) |
Dec
(271) |
2009 |
Jan
(132) |
Feb
(84) |
Mar
(74) |
Apr
(56) |
May
(90) |
Jun
(79) |
Jul
(83) |
Aug
(296) |
Sep
(214) |
Oct
(76) |
Nov
(82) |
Dec
(66) |
2010 |
Jan
(46) |
Feb
(58) |
Mar
(51) |
Apr
(77) |
May
(58) |
Jun
(126) |
Jul
(128) |
Aug
(64) |
Sep
(50) |
Oct
(44) |
Nov
(48) |
Dec
(54) |
2011 |
Jan
(68) |
Feb
(52) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
1
(6) |
2
(17) |
3
(11) |
4
(12) |
5
(16) |
6
(6) |
7
(5) |
8
(8) |
9
(24) |
10
(15) |
11
(12) |
12
(22) |
13
(30) |
14
(16) |
15
(6) |
16
(15) |
17
(20) |
18
(4) |
19
(11) |
20
(16) |
21
(2) |
22
(17) |
23
(16) |
24
(18) |
25
(4) |
26
(9) |
27
(12) |
28
(2) |
29
|
30
(4) |
|
|
|
|
|
Revision: 5701 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5701&view=rev Author: dsdale Date: 2008年06月30日 16:14:42 -0700 (2008年6月30日) Log Message: ----------- another attempt to fix TextWithDash Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/text.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008年06月30日 13:24:13 UTC (rev 5700) +++ trunk/matplotlib/CHANGELOG 2008年06月30日 23:14:42 UTC (rev 5701) @@ -1,3 +1,5 @@ +2008年06月30日 Another attempt to fix TextWithDash - DSD + 2008年06月30日 Removed Qt4 NavigationToolbar2.destroy -- it appears to have been unnecessary and caused a bug reported by P. Raybaut - DSD Modified: trunk/matplotlib/lib/matplotlib/text.py =================================================================== --- trunk/matplotlib/lib/matplotlib/text.py 2008年06月30日 13:24:13 UTC (rev 5700) +++ trunk/matplotlib/lib/matplotlib/text.py 2008年06月30日 23:14:42 UTC (rev 5701) @@ -298,7 +298,12 @@ bbox, info = self._get_layout(renderer) trans = self.get_transform() - posx, posy = self.get_position() + + # don't use self.get_position here, which refers to text position + # in Text, and dash position in TextWithDash: + posx = float(self.convert_xunits(self._x)) + posy = float(self.convert_yunits(self._y)) + posx, posy = trans.transform_point((posx, posy)) canvasw, canvash = renderer.get_canvas_width_height() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5700 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5700&view=rev Author: dsdale Date: 2008年06月30日 06:24:13 -0700 (2008年6月30日) Log Message: ----------- removed Qt4's NavigationToolbar2.destroy method Modified Paths: -------------- branches/v0_91_maint/CHANGELOG branches/v0_91_maint/lib/matplotlib/backends/backend_qt4.py Modified: branches/v0_91_maint/CHANGELOG =================================================================== --- branches/v0_91_maint/CHANGELOG 2008年06月30日 13:21:19 UTC (rev 5699) +++ branches/v0_91_maint/CHANGELOG 2008年06月30日 13:24:13 UTC (rev 5700) @@ -1,3 +1,7 @@ +2008年06月30日 Removed Qt4 NavigationToolbar2.destroy -- it appears to + have been unnecessary and caused a bug reported by P. + Raybaut - DSD + 2008年06月26日 Fix mathtext bug for expressions like $x_{\leftarrow}$ - MGD 2008年06月26日 Fix direction of horizontal/vertical hatches - MGD Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_qt4.py =================================================================== --- branches/v0_91_maint/lib/matplotlib/backends/backend_qt4.py 2008年06月30日 13:21:19 UTC (rev 5699) +++ branches/v0_91_maint/lib/matplotlib/backends/backend_qt4.py 2008年06月30日 13:24:13 UTC (rev 5700) @@ -340,13 +340,6 @@ # reference holder for subplots_adjust window self.adj_window = None - def destroy( self ): - for text, tooltip_text, image_file, callback in self.toolitems: - if text is not None: - QtCore.QObject.disconnect( self.buttons[ text ], - QtCore.SIGNAL( 'clicked()' ), - getattr( self, callback ) ) - def dynamic_update( self ): self.canvas.draw() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5699 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5699&view=rev Author: dsdale Date: 2008年06月30日 06:21:19 -0700 (2008年6月30日) Log Message: ----------- removed Qt4's NavigationToolbar2.destroy method Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008年06月30日 12:13:55 UTC (rev 5698) +++ trunk/matplotlib/CHANGELOG 2008年06月30日 13:21:19 UTC (rev 5699) @@ -1,3 +1,7 @@ +2008年06月30日 Removed Qt4 NavigationToolbar2.destroy -- it appears to + have been unnecessary and caused a bug reported by P. + Raybaut - DSD + 2008年06月27日 Fixed tick positioning bug - MM 2008年06月27日 Fix dashed text bug where text was at the wrong end of the Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2008年06月30日 12:13:55 UTC (rev 5698) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2008年06月30日 13:21:19 UTC (rev 5699) @@ -311,13 +311,6 @@ # reference holder for subplots_adjust window self.adj_window = None - def destroy( self ): - for text, tooltip_text, image_file, callback in self.toolitems: - if text is not None: - QtCore.QObject.disconnect( self.buttons[ text ], - QtCore.SIGNAL( 'clicked()' ), - getattr( self, callback ) ) - def dynamic_update( self ): self.canvas.draw() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5698 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5698&view=rev Author: mdboom Date: 2008年06月30日 05:13:55 -0700 (2008年6月30日) Log Message: ----------- Fixed inverse of natural log bug. (Thanks, Ryan May) Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/scale.py Modified: trunk/matplotlib/lib/matplotlib/scale.py =================================================================== --- trunk/matplotlib/lib/matplotlib/scale.py 2008年06月28日 13:50:45 UTC (rev 5697) +++ trunk/matplotlib/lib/matplotlib/scale.py 2008年06月30日 12:13:55 UTC (rev 5698) @@ -134,7 +134,7 @@ return ma.power(np.e, a) / np.e def inverted(self): - return LogScale.Log2Transform() + return LogScale.NaturalLogTransform() class LogTransform(Transform): input_dims = 1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5697 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5697&view=rev Author: jdh2358 Date: 2008年06月28日 06:50:45 -0700 (2008年6月28日) Log Message: ----------- reverting text with dash fixes; see post on mailing list Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/text.py Modified: trunk/matplotlib/lib/matplotlib/text.py =================================================================== --- trunk/matplotlib/lib/matplotlib/text.py 2008年06月28日 01:10:58 UTC (rev 5696) +++ trunk/matplotlib/lib/matplotlib/text.py 2008年06月28日 13:50:45 UTC (rev 5697) @@ -745,8 +745,8 @@ def get_position(self): "Return x, y as tuple" - x = float(self.convert_xunits(self._x)) - y = float(self.convert_yunits(self._y)) + x = float(self.convert_xunits(self._dashx)) + y = float(self.convert_yunits(self._dashy)) return x, y def get_prop_tup(self): @@ -939,8 +939,7 @@ ACCEPTS: float """ - self._x = float(x) - self._dashx = self._x + self._dashx = float(x) def set_y(self, y): """ @@ -948,8 +947,7 @@ ACCEPTS: float """ - self._y = float(y) - self._dashy = self._y + self._dashy = float(y) def set_transform(self, t): """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5696 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5696&view=rev Author: mmetz_bn Date: 2008年06月27日 18:10:58 -0700 (2008年6月27日) Log Message: ----------- Fixed tick positioning bug Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/text.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008年06月27日 18:54:51 UTC (rev 5695) +++ trunk/matplotlib/CHANGELOG 2008年06月28日 01:10:58 UTC (rev 5696) @@ -1,3 +1,5 @@ +2008年06月27日 Fixed tick positioning bug - MM + 2008年06月27日 Fix dashed text bug where text was at the wrong end of the dash - MGD Modified: trunk/matplotlib/lib/matplotlib/text.py =================================================================== --- trunk/matplotlib/lib/matplotlib/text.py 2008年06月27日 18:54:51 UTC (rev 5695) +++ trunk/matplotlib/lib/matplotlib/text.py 2008年06月28日 01:10:58 UTC (rev 5696) @@ -939,7 +939,8 @@ ACCEPTS: float """ - self._dashx = float(x) + self._x = float(x) + self._dashx = self._x def set_y(self, y): """ @@ -947,7 +948,8 @@ ACCEPTS: float """ - self._dashy = float(y) + self._y = float(y) + self._dashy = self._y def set_transform(self, t): """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5695 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5695&view=rev Author: mdboom Date: 2008年06月27日 11:54:51 -0700 (2008年6月27日) Log Message: ----------- Fix Figure.add_axes docstring formatting bugs. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/figure.py Modified: trunk/matplotlib/lib/matplotlib/figure.py =================================================================== --- trunk/matplotlib/lib/matplotlib/figure.py 2008年06月27日 18:53:11 UTC (rev 5694) +++ trunk/matplotlib/lib/matplotlib/figure.py 2008年06月27日 18:54:51 UTC (rev 5695) @@ -636,13 +636,15 @@ def add_axes(self, *args, **kwargs): """ - Add an a axes with axes rect [left, bottom, width, height] where all - quantities are in fractions of figure width and height. kwargs are - legal Axes kwargs plus "projection" which sets the projection type - of the axes. (For backward compatibility, *polar=True* may also be - provided, which is equivalent to *projection='polar'*). - Valid values for "projection" are: %s. Some of these projections - support additional kwargs, which may be provided to add_axes:: + Add an a axes with axes rect [*left*, *bottom*, *width*, + *height*] where all quantities are in fractions of figure + width and height. kwargs are legal + :class:`~matplotlib.axes.Axes` kwargs plus *projection* which + sets the projection type of the axes. (For backward + compatibility, ``polar=True`` may also be provided, which is + equivalent to ``projection='polar'``). Valid values for + *projection* are: %s. Some of these projections support + additional kwargs, which may be provided to :meth:`add_axes`:: rect = l,b,w,h fig.add_axes(rect) @@ -651,13 +653,14 @@ fig.add_axes(rect, projection='polar') fig.add_axes(ax) # add an Axes instance - If the figure already has an axes with key *args, *kwargs then it will - simply make that axes current and return it. If you do not want this - behavior, eg you want to force the creation of a new axes, you must - use a unique set of args and kwargs. The artist "label" attribute has - been exposed for this purpose. Eg, if you want two axes that are - otherwise identical to be added to the figure, make sure you give them - unique labels:: + If the figure already has an axes with the same parameters, + then it will simply make that axes current and return it. If + you do not want this behavior, eg. you want to force the + creation of a new axes, you must use a unique set of args and + kwargs. The axes :attr:`~matplotlib.axes.Axes.label` + attribute has been exposed for this purpose. Eg., if you want + two axes that are otherwise identical to be added to the + figure, make sure you give them unique labels:: fig.add_axes(rect, label='axes1') fig.add_axes(rect, label='axes2') @@ -665,8 +668,9 @@ The :class:`~matplotlib.axes.Axes` instance will be returned. The following kwargs are supported: + %s - """ % (", ".join(get_projection_names()), '%(Axes)s') + """ key = self._make_key(*args, **kwargs) @@ -699,6 +703,7 @@ self._seen[key] = a return a + add_axes.__doc__ = add_axes.__doc__ % (", ".join(get_projection_names()), '%(Axes)s') add_axes.__doc__ = dedent(add_axes.__doc__) % artist.kwdocd def add_subplot(self, *args, **kwargs): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5694 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5694&view=rev Author: mdboom Date: 2008年06月27日 11:53:11 -0700 (2008年6月27日) Log Message: ----------- Fix dashed text bug where text was at the wrong end of the dash (Thanks Andrea Gavana) Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/text.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008年06月27日 15:42:44 UTC (rev 5693) +++ trunk/matplotlib/CHANGELOG 2008年06月27日 18:53:11 UTC (rev 5694) @@ -1,3 +1,6 @@ +2008年06月27日 Fix dashed text bug where text was at the wrong end of the + dash - MGD + 2008年06月26日 Fix mathtext bug for expressions like $x_{\leftarrow}$ - MGD 2008年06月26日 Fix direction of horizontal/vertical hatches - MGD Modified: trunk/matplotlib/lib/matplotlib/text.py =================================================================== --- trunk/matplotlib/lib/matplotlib/text.py 2008年06月27日 15:42:44 UTC (rev 5693) +++ trunk/matplotlib/lib/matplotlib/text.py 2008年06月27日 18:53:11 UTC (rev 5694) @@ -745,8 +745,8 @@ def get_position(self): "Return x, y as tuple" - x = float(self.convert_xunits(self._dashx)) - y = float(self.convert_yunits(self._dashy)) + x = float(self.convert_xunits(self._x)) + y = float(self.convert_yunits(self._y)) return x, y def get_prop_tup(self): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5689 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5689&view=rev Author: jdh2358 Date: 2008年06月27日 08:33:17 -0700 (2008年6月27日) Log Message: ----------- fixed errorbar demo Modified Paths: -------------- trunk/matplotlib/doc/sphinxext/plot_directive.py trunk/matplotlib/lib/matplotlib/contour.py Modified: trunk/matplotlib/doc/sphinxext/plot_directive.py =================================================================== --- trunk/matplotlib/doc/sphinxext/plot_directive.py 2008年06月27日 15:25:50 UTC (rev 5688) +++ trunk/matplotlib/doc/sphinxext/plot_directive.py 2008年06月27日 15:33:17 UTC (rev 5689) @@ -43,7 +43,7 @@ template = """ .. htmlonly:: - [`py <../%(srcdir)s/%(basename)s.py>`__, + [`source code <../%(srcdir)s/%(basename)s.py>`__, `png <../%(srcdir)s/%(basename)s.hires.png>`__, `pdf <../%(srcdir)s/%(basename)s.pdf>`__] Modified: trunk/matplotlib/lib/matplotlib/contour.py =================================================================== --- trunk/matplotlib/lib/matplotlib/contour.py 2008年06月27日 15:25:50 UTC (rev 5688) +++ trunk/matplotlib/lib/matplotlib/contour.py 2008年06月27日 15:33:17 UTC (rev 5689) @@ -893,5 +893,7 @@ be removed. Chunking introduces artifacts at the chunk boundaries unless *antialiased* is *False*. + **Example:** + .. plot:: contour_demo.py """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5691 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5691&view=rev Author: jdh2358 Date: 2008年06月27日 08:39:28 -0700 (2008年6月27日) Log Message: ----------- removing the copied files I accidentally added (sigh). It is confusing to put autogenerated files next to legit files in pyplot... Removed Paths: ------------- trunk/matplotlib/doc/pyplots/arrow_demo.py trunk/matplotlib/doc/pyplots/axhspan_demo.py trunk/matplotlib/doc/pyplots/bar_stacked.py trunk/matplotlib/doc/pyplots/broken_barh.py trunk/matplotlib/doc/pyplots/cohere_demo.py trunk/matplotlib/doc/pyplots/csd_demo.py trunk/matplotlib/doc/pyplots/figimage_demo.py trunk/matplotlib/doc/pyplots/figlegend_demo.py trunk/matplotlib/doc/pyplots/fill_demo.py trunk/matplotlib/doc/pyplots/hexbin_demo.py trunk/matplotlib/doc/pyplots/histogram_demo.py trunk/matplotlib/doc/pyplots/image_demo.py trunk/matplotlib/doc/pyplots/log_demo.py trunk/matplotlib/doc/pyplots/xcorr_demo.py Deleted: trunk/matplotlib/doc/pyplots/arrow_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/arrow_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) +++ trunk/matplotlib/doc/pyplots/arrow_demo.py 2008年06月27日 15:39:28 UTC (rev 5691) @@ -1,313 +0,0 @@ -#!/usr/bin/env python -"""Arrow drawing example for the new fancy_arrow facilities. - -Code contributed by: Rob Knight <ro...@sp...> - -usage: - - python arrow_demo.py realistic|full|sample|extreme - - -""" -from pylab import * - -rates_to_bases={'r1':'AT', 'r2':'TA', 'r3':'GA','r4':'AG','r5':'CA','r6':'AC', \ - 'r7':'GT', 'r8':'TG', 'r9':'CT','r10':'TC','r11':'GC','r12':'CG'} -numbered_bases_to_rates = dict([(v,k) for k, v in rates_to_bases.items()]) -lettered_bases_to_rates = dict([(v, 'r'+v) for k, v in rates_to_bases.items()]) -def add_dicts(d1, d2): - """Adds two dicts and returns the result.""" - result = d1.copy() - result.update(d2) - return result - -def make_arrow_plot(data, size=4, display='length', shape='right', \ - max_arrow_width=0.03, arrow_sep = 0.02, alpha=0.5, \ - normalize_data=False, ec=None, labelcolor=None, \ - head_starts_at_zero=True, rate_labels=lettered_bases_to_rates,\ - **kwargs): - """Makes an arrow plot. - - Parameters: - - data: dict with probabilities for the bases and pair transitions. - size: size of the graph in inches. - display: 'length', 'width', or 'alpha' for arrow property to change. - shape: 'full', 'left', or 'right' for full or half arrows. - max_arrow_width: maximum width of an arrow, data coordinates. - arrow_sep: separation between arrows in a pair, data coordinates. - alpha: maximum opacity of arrows, default 0.8. - - **kwargs can be anything allowed by a Arrow object, e.g. - linewidth and edgecolor. - """ - - xlim(-0.5,1.5) - ylim(-0.5,1.5) - gcf().set_size_inches(size,size) - xticks([]) - yticks([]) - max_text_size = size*12 - min_text_size = size - label_text_size = size*2.5 - text_params={'ha':'center', 'va':'center', 'family':'sans-serif',\ - 'fontweight':'bold'} - r2 = sqrt(2) - - deltas = {\ - 'AT':(1,0), - 'TA':(-1,0), - 'GA':(0,1), - 'AG':(0,-1), - 'CA':(-1/r2, 1/r2), - 'AC':(1/r2, -1/r2), - 'GT':(1/r2, 1/r2), - 'TG':(-1/r2,-1/r2), - 'CT':(0,1), - 'TC':(0,-1), - 'GC':(1,0), - 'CG':(-1,0) - } - - colors = {\ - 'AT':'r', - 'TA':'k', - 'GA':'g', - 'AG':'r', - 'CA':'b', - 'AC':'r', - 'GT':'g', - 'TG':'k', - 'CT':'b', - 'TC':'k', - 'GC':'g', - 'CG':'b' - } - - label_positions = {\ - 'AT':'center', - 'TA':'center', - 'GA':'center', - 'AG':'center', - 'CA':'left', - 'AC':'left', - 'GT':'left', - 'TG':'left', - 'CT':'center', - 'TC':'center', - 'GC':'center', - 'CG':'center' - } - - - def do_fontsize(k): - return float(clip(max_text_size*sqrt(data[k]),\ - min_text_size,max_text_size)) - - A = text(0,1, '$A_3$', color='r', size=do_fontsize('A'), **text_params) - T = text(1,1, '$T_3$', color='k', size=do_fontsize('T'), **text_params) - G = text(0,0, '$G_3$', color='g', size=do_fontsize('G'), **text_params) - C = text(1,0, '$C_3$', color='b', size=do_fontsize('C'), **text_params) - - arrow_h_offset = 0.25 #data coordinates, empirically determined - max_arrow_length = 1 - 2*arrow_h_offset - - max_arrow_width = max_arrow_width - max_head_width = 2.5*max_arrow_width - max_head_length = 2*max_arrow_width - arrow_params={'length_includes_head':True, 'shape':shape, \ - 'head_starts_at_zero':head_starts_at_zero} - ax = gca() - sf = 0.6 #max arrow size represents this in data coords - - d = (r2/2 + arrow_h_offset - 0.5)/r2 #distance for diags - r2v = arrow_sep/r2 #offset for diags - - #tuple of x, y for start position - positions = {\ - 'AT': (arrow_h_offset, 1+arrow_sep), - 'TA': (1-arrow_h_offset, 1-arrow_sep), - 'GA': (-arrow_sep, arrow_h_offset), - 'AG': (arrow_sep, 1-arrow_h_offset), - 'CA': (1-d-r2v, d-r2v), - 'AC': (d+r2v, 1-d+r2v), - 'GT': (d-r2v, d+r2v), - 'TG': (1-d+r2v, 1-d-r2v), - 'CT': (1-arrow_sep, arrow_h_offset), - 'TC': (1+arrow_sep, 1-arrow_h_offset), - 'GC': (arrow_h_offset, arrow_sep), - 'CG': (1-arrow_h_offset, -arrow_sep), - } - - if normalize_data: - #find maximum value for rates, i.e. where keys are 2 chars long - max_val = 0 - for k, v in data.items(): - if len(k) == 2: - max_val = max(max_val, v) - #divide rates by max val, multiply by arrow scale factor - for k, v in data.items(): - data[k] = v/max_val*sf - - def draw_arrow(pair, alpha=alpha, ec=ec, labelcolor=labelcolor): - #set the length of the arrow - if display == 'length': - length = max_head_length+(max_arrow_length-max_head_length)*\ - data[pair]/sf - else: - length = max_arrow_length - #set the transparency of the arrow - if display == 'alph': - alpha = min(data[pair]/sf, alpha) - else: - alpha=alpha - #set the width of the arrow - if display == 'width': - scale = data[pair]/sf - width = max_arrow_width*scale - head_width = max_head_width*scale - head_length = max_head_length*scale - else: - width = max_arrow_width - head_width = max_head_width - head_length = max_head_length - - fc = colors[pair] - ec = ec or fc - - x_scale, y_scale = deltas[pair] - x_pos, y_pos = positions[pair] - arrow(x_pos, y_pos, x_scale*length, y_scale*length, \ - fc=fc, ec=ec, alpha=alpha, width=width, head_width=head_width, \ - head_length=head_length, **arrow_params) - - #figure out coordinates for text - #if drawing relative to base: x and y are same as for arrow - #dx and dy are one arrow width left and up - #need to rotate based on direction of arrow, use x_scale and y_scale - #as sin x and cos x? - sx, cx = y_scale, x_scale - - where = label_positions[pair] - if where == 'left': - orig_position = 3*array([[max_arrow_width, max_arrow_width]]) - elif where == 'absolute': - orig_position = array([[max_arrow_length/2.0, 3*max_arrow_width]]) - elif where == 'right': - orig_position = array([[length-3*max_arrow_width,\ - 3*max_arrow_width]]) - elif where == 'center': - orig_position = array([[length/2.0, 3*max_arrow_width]]) - else: - raise ValueError, "Got unknown position parameter %s" % where - - - - M = array([[cx, sx],[-sx,cx]]) - coords = dot(orig_position, M) + [[x_pos, y_pos]] - x, y = ravel(coords) - orig_label = rate_labels[pair] - label = '$%s_{_{\mathrm{%s}}}$' % (orig_label[0], orig_label[1:]) - - text(x, y, label, size=label_text_size, ha='center', va='center', \ - color=labelcolor or fc) - - for p in positions.keys(): - draw_arrow(p) - - #test data -all_on_max = dict([(i, 1) for i in 'TCAG'] + \ - [(i+j, 0.6) for i in 'TCAG' for j in 'TCAG']) - -realistic_data = { - 'A':0.4, - 'T':0.3, - 'G':0.5, - 'C':0.2, - 'AT':0.4, - 'AC':0.3, - 'AG':0.2, - 'TA':0.2, - 'TC':0.3, - 'TG':0.4, - 'CT':0.2, - 'CG':0.3, - 'CA':0.2, - 'GA':0.1, - 'GT':0.4, - 'GC':0.1, - } - -extreme_data = { - 'A':0.75, - 'T':0.10, - 'G':0.10, - 'C':0.05, - 'AT':0.6, - 'AC':0.3, - 'AG':0.1, - 'TA':0.02, - 'TC':0.3, - 'TG':0.01, - 'CT':0.2, - 'CG':0.5, - 'CA':0.2, - 'GA':0.1, - 'GT':0.4, - 'GC':0.2, - } - -sample_data = { - 'A':0.2137, - 'T':0.3541, - 'G':0.1946, - 'C':0.2376, - 'AT':0.0228, - 'AC':0.0684, - 'AG':0.2056, - 'TA':0.0315, - 'TC':0.0629, - 'TG':0.0315, - 'CT':0.1355, - 'CG':0.0401, - 'CA':0.0703, - 'GA':0.1824, - 'GT':0.0387, - 'GC':0.1106, - } - - -if __name__ == '__main__': - from sys import argv - d = None - if len(argv) > 1: - if argv[1] == 'full': - d = all_on_max - scaled = False - elif argv[1] == 'extreme': - d = extreme_data - scaled = False - elif argv[1] == 'realistic': - d = realistic_data - scaled = False - elif argv[1] == 'sample': - d = sample_data - scaled = True - if d is None: - d = all_on_max - scaled=False - if len(argv) > 2: - display = argv[2] - else: - display = 'length' - - size = 4 - figure(figsize=(size,size)) - - make_arrow_plot(d, display=display, linewidth=0.001, edgecolor=None, - normalize_data=scaled, head_starts_at_zero=True, size=size) - - draw() - #savefig('arrows.png') - #print 'Example saved to file "arrows.png"' - show() Deleted: trunk/matplotlib/doc/pyplots/axhspan_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/axhspan_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) +++ trunk/matplotlib/doc/pyplots/axhspan_demo.py 2008年06月27日 15:39:28 UTC (rev 5691) @@ -1,32 +0,0 @@ -import numpy as np -import matplotlib.pyplot as plt - -t = np.arange(-1,2, .01) -s = np.sin(2*np.pi*t) - -plt.plot(t,s) -# draw a thick red hline at y=0 that spans the xrange -l = plt.axhline(linewidth=4, color='r') - -# draw a default hline at y=1 that spans the xrange -l = plt.axhline(y=1) - -# draw a default vline at x=1 that spans the xrange -l = plt.axvline(x=1) - -# draw a thick blue vline at x=0 that spans the the upper quadrant of -# the yrange -l = plt.axvline(x=0, ymin=0.75, linewidth=4, color='b') - -# draw a default hline at y=.5 that spans the the middle half of -# the axes -l = plt.axhline(y=.5, xmin=0.25, xmax=0.75) - -p = plt.axhspan(0.25, 0.75, facecolor='0.5', alpha=0.5) - -p = plt.axvspan(1.25, 1.55, facecolor='g', alpha=0.5) - -plt.axis([-1,2,-1,2]) - - -plt.show() Deleted: trunk/matplotlib/doc/pyplots/bar_stacked.py =================================================================== --- trunk/matplotlib/doc/pyplots/bar_stacked.py 2008年06月27日 15:34:32 UTC (rev 5690) +++ trunk/matplotlib/doc/pyplots/bar_stacked.py 2008年06月27日 15:39:28 UTC (rev 5691) @@ -1,25 +0,0 @@ -#!/usr/bin/env python -# a stacked bar plot with errorbars -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 - -p1 = plt.bar(ind, menMeans, width, color='r', yerr=womenStd) -p2 = plt.bar(ind, womenMeans, width, color='y', - bottom=menMeans, yerr=menStd) - -plt.ylabel('Scores') -plt.title('Scores by group and gender') -plt.xticks(ind+width/2., ('G1', 'G2', 'G3', 'G4', 'G5') ) -plt.yticks(np.arange(0,81,10)) -plt.legend( (p1[0], p2[0]), ('Men', 'Women') ) - -plt.show() Deleted: trunk/matplotlib/doc/pyplots/broken_barh.py =================================================================== --- trunk/matplotlib/doc/pyplots/broken_barh.py 2008年06月27日 15:34:32 UTC (rev 5690) +++ trunk/matplotlib/doc/pyplots/broken_barh.py 2008年06月27日 15:39:28 UTC (rev 5691) @@ -1,24 +0,0 @@ -""" -Make a "broken" horizontal bar plot, ie one with gaps -""" -import matplotlib.pyplot as plt - -fig = plt.figure() -ax = fig.add_subplot(111) -ax.broken_barh([ (110, 30), (150, 10) ] , (10, 9), facecolors='blue') -ax.broken_barh([ (10, 50), (100, 20), (130, 10)] , (20, 9), - facecolors=('red', 'yellow', 'green')) -ax.set_ylim(5,35) -ax.set_xlim(0,200) -ax.set_xlabel('seconds since start') -ax.set_yticks([15,25]) -ax.set_yticklabels(['Bill', 'Jim']) -ax.grid(True) -ax.annotate('race interrupted', (61, 25), - xytext=(0.8, 0.9), textcoords='axes fraction', - arrowprops=dict(facecolor='black', shrink=0.05), - fontsize=16, - horizontalalignment='right', verticalalignment='top') - -#fig.savefig('broken_barh', dpi=100) -plt.show() Deleted: trunk/matplotlib/doc/pyplots/cohere_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/cohere_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) +++ trunk/matplotlib/doc/pyplots/cohere_demo.py 2008年06月27日 15:39:28 UTC (rev 5691) @@ -1,36 +0,0 @@ -#!/usr/bin/env python -""" -Compute the coherence of two signals -""" -import numpy as np -import matplotlib.pyplot as plt - -# make a little extra space between the subplots -plt.subplots_adjust(wspace=0.5) - -dt = 0.01 -t = np.arange(0, 30, dt) -nse1 = np.random.randn(len(t)) # white noise 1 -nse2 = np.random.randn(len(t)) # white noise 2 -r = np.exp(-t/0.05) - -cnse1 = np.convolve(nse1, r, mode='same')*dt # colored noise 1 -cnse2 = np.convolve(nse2, r, mode='same')*dt # colored noise 2 - -# two signals with a coherent part and a random part -s1 = 0.01*np.sin(2*np.pi*10*t) + cnse1 -s2 = 0.01*np.sin(2*np.pi*10*t) + cnse2 - -plt.subplot(211) -plt.plot(t, s1, 'b-', t, s2, 'g-') -plt.xlim(0,5) -plt.xlabel('time') -plt.ylabel('s1 and s2') -plt.grid(True) - -plt.subplot(212) -cxy, f = plt.cohere(s1, s2, 256, 1./dt) -plt.ylabel('coherence') -plt.show() - - Deleted: trunk/matplotlib/doc/pyplots/csd_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/csd_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) +++ trunk/matplotlib/doc/pyplots/csd_demo.py 2008年06月27日 15:39:28 UTC (rev 5691) @@ -1,36 +0,0 @@ -#!/usr/bin/env python -""" -Compute the cross spectral density of two signals -""" -import numpy as np -import matplotlib.pyplot as plt - -# make a little extra space between the subplots -plt.subplots_adjust(wspace=0.5) - -dt = 0.01 -t = np.arange(0, 30, dt) -nse1 = np.random.randn(len(t)) # white noise 1 -nse2 = np.random.randn(len(t)) # white noise 2 -r = np.exp(-t/0.05) - -cnse1 = np.convolve(nse1, r, mode='same')*dt # colored noise 1 -cnse2 = np.convolve(nse2, r, mode='same')*dt # colored noise 2 - -# two signals with a coherent part and a random part -s1 = 0.01*np.sin(2*np.pi*10*t) + cnse1 -s2 = 0.01*np.sin(2*np.pi*10*t) + cnse2 - -plt.subplot(211) -plt.plot(t, s1, 'b-', t, s2, 'g-') -plt.xlim(0,5) -plt.xlabel('time') -plt.ylabel('s1 and s2') -plt.grid(True) - -plt.subplot(212) -cxy, f = plt.csd(s1, s2, 256, 1./dt) -plt.ylabel('CSD (db)') -plt.show() - - Deleted: trunk/matplotlib/doc/pyplots/figimage_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/figimage_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) +++ trunk/matplotlib/doc/pyplots/figimage_demo.py 2008年06月27日 15:39:28 UTC (rev 5691) @@ -1,21 +0,0 @@ -""" -See pcolor_demo2 for a much faster way of generating pcolor plots -""" -import numpy as np -import matplotlib -import matplotlib.cm as cm -import matplotlib.pyplot as plt - - -fig = plt.figure(frameon=False) -Z = np.arange(10000.0) -Z.shape = 100,100 -Z[:,50:] = 1. - -im1 = plt.figimage(Z, xo=50, yo=0, cmap=cm.jet) -im2 = plt.figimage(Z, xo=100, yo=100, alpha=.8, cmap=cm.jet) - -plt.show() - - - Deleted: trunk/matplotlib/doc/pyplots/figlegend_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/figlegend_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) +++ trunk/matplotlib/doc/pyplots/figlegend_demo.py 2008年06月27日 15:39:28 UTC (rev 5691) @@ -1,19 +0,0 @@ -import numpy as np -import matplotlib.pyplot as plt - -fig = plt.figure() -ax1 = fig.add_axes([0.1, 0.1, 0.4, 0.7]) -ax2 = fig.add_axes([0.55, 0.1, 0.4, 0.7]) - -x = np.arange(0.0, 2.0, 0.02) -y1 = np.sin(2*np.pi*x) -y2 = np.exp(-x) -l1, l2 = ax1.plot(x, y1, 'rs-', x, y2, 'go') - -y3 = np.sin(4*np.pi*x) -y4 = np.exp(-2*x) -l3, l4 = ax2.plot(x, y3, 'yd-', x, y3, 'k^') - -fig.legend((l1, l2), ('Line 1', 'Line 2'), 'upper left') -fig.legend((l3, l4), ('Line 3', 'Line 4'), 'upper right') -plt.show() Deleted: trunk/matplotlib/doc/pyplots/fill_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/fill_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) +++ trunk/matplotlib/doc/pyplots/fill_demo.py 2008年06月27日 15:39:28 UTC (rev 5691) @@ -1,10 +0,0 @@ -#!/usr/bin/env python -import numpy as np -import matplotlib.pyplot as plt - -t = np.arange(0.0, 1.01, 0.01) -s = np.sin(2*2*np.pi*t) - -plt.fill(t, s*np.exp(-5*t), 'r') -plt.grid(True) -plt.show() Deleted: trunk/matplotlib/doc/pyplots/hexbin_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/hexbin_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) +++ trunk/matplotlib/doc/pyplots/hexbin_demo.py 2008年06月27日 15:39:28 UTC (rev 5691) @@ -1,34 +0,0 @@ -""" -hexbin is an axes method or pyplot function that is essentially -a pcolor of a 2-D histogram with hexagonal cells. It can be -much more informative than a scatter plot; in the first subplot -below, try substituting 'scatter' for 'hexbin'. -""" - -import numpy as np -import matplotlib.pyplot as plt -n = 100000 -x = np.random.standard_normal(n) -y = 2.0 + 3.0 * x + 4.0 * np.random.standard_normal(n) -xmin = x.min() -xmax = x.max() -ymin = y.min() -ymax = y.max() - -plt.subplots_adjust(hspace=0.5) -plt.subplot(121) -plt.hexbin(x,y) -plt.axis([xmin, xmax, ymin, ymax]) -plt.title("Hexagon binning") -cb = plt.colorbar() -cb.set_label('counts') - -plt.subplot(122) -plt.hexbin(x,y,bins='log') -plt.axis([xmin, xmax, ymin, ymax]) -plt.title("With a log color scale") -cb = plt.colorbar() -cb.set_label('log10(N)') - -plt.show() - Deleted: trunk/matplotlib/doc/pyplots/histogram_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/histogram_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) +++ trunk/matplotlib/doc/pyplots/histogram_demo.py 2008年06月27日 15:39:28 UTC (rev 5691) @@ -1,22 +0,0 @@ -#!/usr/bin/env python -import numpy as np -import matplotlib.mlab as mlab -import matplotlib.pyplot as plt - -mu, sigma = 100, 15 -x = mu + sigma*np.random.randn(10000) - -# the histogram of the data -n, bins, patches = plt.hist(x, 50, normed=1, facecolor='green', alpha=0.75) - -# add a 'best fit' line -y = mlab.normpdf( bins, mu, sigma) -l = plt.plot(bins, y, 'r--', linewidth=1) - -plt.xlabel('Smarts') -plt.ylabel('Probability') -plt.title(r'$\mathrm{Histogram\ of\ IQ:}\ \mu=100,\ \sigma=15$') -plt.axis([40, 160, 0, 0.03]) -plt.grid(True) - -plt.show() Deleted: trunk/matplotlib/doc/pyplots/image_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/image_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) +++ trunk/matplotlib/doc/pyplots/image_demo.py 2008年06月27日 15:39:28 UTC (rev 5691) @@ -1,18 +0,0 @@ -#!/usr/bin/env python -import numpy as np -import matplotlib.cm as cm -import matplotlib.mlab as mlab -import matplotlib.pyplot as plt - -delta = 0.025 -x = y = np.arange(-3.0, 3.0, delta) -X, Y = np.meshgrid(x, y) -Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) -Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1) -Z = Z2-Z1 # difference of Gaussians - -im = plt.imshow(Z, interpolation='bilinear', cmap=cm.gray, - origin='lower', extent=[-3,3,-3,3]) - -plt.show() - Deleted: trunk/matplotlib/doc/pyplots/log_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/log_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) +++ trunk/matplotlib/doc/pyplots/log_demo.py 2008年06月27日 15:39:28 UTC (rev 5691) @@ -1,25 +0,0 @@ -import numpy as np -import matplotlib.pyplot as plt - -plt.subplots_adjust(hspace=0.4) -t = np.arange(0.01, 20.0, 0.01) - -# log y axis -plt.subplot(311) -plt.semilogy(t, np.exp(-t/5.0)) -plt.ylabel('semilogy') -plt.grid(True) - -# log x axis -plt.subplot(312) -plt.semilogx(t, np.sin(2*np.pi*t)) -plt.ylabel('semilogx') -plt.grid(True) - -# log x and y axis -plt.subplot(313) -plt.loglog(t, 20*np.exp(-t/10.0), basex=4) -plt.grid(True) -plt.ylabel('loglog base 4 on x') - -plt.show() Deleted: trunk/matplotlib/doc/pyplots/xcorr_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/xcorr_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) +++ trunk/matplotlib/doc/pyplots/xcorr_demo.py 2008年06月27日 15:39:28 UTC (rev 5691) @@ -1,17 +0,0 @@ -import matplotlib.pyplot as plt -import numpy as np - -x,y = np.random.randn(2,100) -fig = plt.figure() -ax1 = fig.add_subplot(211) -ax1.xcorr(x, y, usevlines=True, maxlags=50, normed=True, lw=2) -ax1.grid(True) -ax1.axhline(0, color='black', lw=2) - -ax2 = fig.add_subplot(212, sharex=ax1) -ax2.acorr(x, usevlines=True, normed=True, maxlags=50, lw=2) -ax2.grid(True) -ax2.axhline(0, color='black', lw=2) - -plt.show() - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5690 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5690&view=rev Author: jdh2358 Date: 2008年06月27日 08:34:32 -0700 (2008年6月27日) Log Message: ----------- added pyplots examples which I forgot to svn add in prev commit Added Paths: ----------- trunk/matplotlib/doc/pyplots/arrow_demo.py trunk/matplotlib/doc/pyplots/axhspan_demo.py trunk/matplotlib/doc/pyplots/bar_stacked.py trunk/matplotlib/doc/pyplots/boxplot_demo.py trunk/matplotlib/doc/pyplots/broken_barh.py trunk/matplotlib/doc/pyplots/cohere_demo.py trunk/matplotlib/doc/pyplots/contour_demo.py trunk/matplotlib/doc/pyplots/csd_demo.py trunk/matplotlib/doc/pyplots/errorbar_demo.py trunk/matplotlib/doc/pyplots/figimage_demo.py trunk/matplotlib/doc/pyplots/figlegend_demo.py trunk/matplotlib/doc/pyplots/fill_demo.py trunk/matplotlib/doc/pyplots/hexbin_demo.py trunk/matplotlib/doc/pyplots/histogram_demo.py trunk/matplotlib/doc/pyplots/hline_demo.py trunk/matplotlib/doc/pyplots/image_demo.py trunk/matplotlib/doc/pyplots/log_demo.py trunk/matplotlib/doc/pyplots/xcorr_demo.py Added: trunk/matplotlib/doc/pyplots/arrow_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/arrow_demo.py (rev 0) +++ trunk/matplotlib/doc/pyplots/arrow_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) @@ -0,0 +1,313 @@ +#!/usr/bin/env python +"""Arrow drawing example for the new fancy_arrow facilities. + +Code contributed by: Rob Knight <ro...@sp...> + +usage: + + python arrow_demo.py realistic|full|sample|extreme + + +""" +from pylab import * + +rates_to_bases={'r1':'AT', 'r2':'TA', 'r3':'GA','r4':'AG','r5':'CA','r6':'AC', \ + 'r7':'GT', 'r8':'TG', 'r9':'CT','r10':'TC','r11':'GC','r12':'CG'} +numbered_bases_to_rates = dict([(v,k) for k, v in rates_to_bases.items()]) +lettered_bases_to_rates = dict([(v, 'r'+v) for k, v in rates_to_bases.items()]) +def add_dicts(d1, d2): + """Adds two dicts and returns the result.""" + result = d1.copy() + result.update(d2) + return result + +def make_arrow_plot(data, size=4, display='length', shape='right', \ + max_arrow_width=0.03, arrow_sep = 0.02, alpha=0.5, \ + normalize_data=False, ec=None, labelcolor=None, \ + head_starts_at_zero=True, rate_labels=lettered_bases_to_rates,\ + **kwargs): + """Makes an arrow plot. + + Parameters: + + data: dict with probabilities for the bases and pair transitions. + size: size of the graph in inches. + display: 'length', 'width', or 'alpha' for arrow property to change. + shape: 'full', 'left', or 'right' for full or half arrows. + max_arrow_width: maximum width of an arrow, data coordinates. + arrow_sep: separation between arrows in a pair, data coordinates. + alpha: maximum opacity of arrows, default 0.8. + + **kwargs can be anything allowed by a Arrow object, e.g. + linewidth and edgecolor. + """ + + xlim(-0.5,1.5) + ylim(-0.5,1.5) + gcf().set_size_inches(size,size) + xticks([]) + yticks([]) + max_text_size = size*12 + min_text_size = size + label_text_size = size*2.5 + text_params={'ha':'center', 'va':'center', 'family':'sans-serif',\ + 'fontweight':'bold'} + r2 = sqrt(2) + + deltas = {\ + 'AT':(1,0), + 'TA':(-1,0), + 'GA':(0,1), + 'AG':(0,-1), + 'CA':(-1/r2, 1/r2), + 'AC':(1/r2, -1/r2), + 'GT':(1/r2, 1/r2), + 'TG':(-1/r2,-1/r2), + 'CT':(0,1), + 'TC':(0,-1), + 'GC':(1,0), + 'CG':(-1,0) + } + + colors = {\ + 'AT':'r', + 'TA':'k', + 'GA':'g', + 'AG':'r', + 'CA':'b', + 'AC':'r', + 'GT':'g', + 'TG':'k', + 'CT':'b', + 'TC':'k', + 'GC':'g', + 'CG':'b' + } + + label_positions = {\ + 'AT':'center', + 'TA':'center', + 'GA':'center', + 'AG':'center', + 'CA':'left', + 'AC':'left', + 'GT':'left', + 'TG':'left', + 'CT':'center', + 'TC':'center', + 'GC':'center', + 'CG':'center' + } + + + def do_fontsize(k): + return float(clip(max_text_size*sqrt(data[k]),\ + min_text_size,max_text_size)) + + A = text(0,1, '$A_3$', color='r', size=do_fontsize('A'), **text_params) + T = text(1,1, '$T_3$', color='k', size=do_fontsize('T'), **text_params) + G = text(0,0, '$G_3$', color='g', size=do_fontsize('G'), **text_params) + C = text(1,0, '$C_3$', color='b', size=do_fontsize('C'), **text_params) + + arrow_h_offset = 0.25 #data coordinates, empirically determined + max_arrow_length = 1 - 2*arrow_h_offset + + max_arrow_width = max_arrow_width + max_head_width = 2.5*max_arrow_width + max_head_length = 2*max_arrow_width + arrow_params={'length_includes_head':True, 'shape':shape, \ + 'head_starts_at_zero':head_starts_at_zero} + ax = gca() + sf = 0.6 #max arrow size represents this in data coords + + d = (r2/2 + arrow_h_offset - 0.5)/r2 #distance for diags + r2v = arrow_sep/r2 #offset for diags + + #tuple of x, y for start position + positions = {\ + 'AT': (arrow_h_offset, 1+arrow_sep), + 'TA': (1-arrow_h_offset, 1-arrow_sep), + 'GA': (-arrow_sep, arrow_h_offset), + 'AG': (arrow_sep, 1-arrow_h_offset), + 'CA': (1-d-r2v, d-r2v), + 'AC': (d+r2v, 1-d+r2v), + 'GT': (d-r2v, d+r2v), + 'TG': (1-d+r2v, 1-d-r2v), + 'CT': (1-arrow_sep, arrow_h_offset), + 'TC': (1+arrow_sep, 1-arrow_h_offset), + 'GC': (arrow_h_offset, arrow_sep), + 'CG': (1-arrow_h_offset, -arrow_sep), + } + + if normalize_data: + #find maximum value for rates, i.e. where keys are 2 chars long + max_val = 0 + for k, v in data.items(): + if len(k) == 2: + max_val = max(max_val, v) + #divide rates by max val, multiply by arrow scale factor + for k, v in data.items(): + data[k] = v/max_val*sf + + def draw_arrow(pair, alpha=alpha, ec=ec, labelcolor=labelcolor): + #set the length of the arrow + if display == 'length': + length = max_head_length+(max_arrow_length-max_head_length)*\ + data[pair]/sf + else: + length = max_arrow_length + #set the transparency of the arrow + if display == 'alph': + alpha = min(data[pair]/sf, alpha) + else: + alpha=alpha + #set the width of the arrow + if display == 'width': + scale = data[pair]/sf + width = max_arrow_width*scale + head_width = max_head_width*scale + head_length = max_head_length*scale + else: + width = max_arrow_width + head_width = max_head_width + head_length = max_head_length + + fc = colors[pair] + ec = ec or fc + + x_scale, y_scale = deltas[pair] + x_pos, y_pos = positions[pair] + arrow(x_pos, y_pos, x_scale*length, y_scale*length, \ + fc=fc, ec=ec, alpha=alpha, width=width, head_width=head_width, \ + head_length=head_length, **arrow_params) + + #figure out coordinates for text + #if drawing relative to base: x and y are same as for arrow + #dx and dy are one arrow width left and up + #need to rotate based on direction of arrow, use x_scale and y_scale + #as sin x and cos x? + sx, cx = y_scale, x_scale + + where = label_positions[pair] + if where == 'left': + orig_position = 3*array([[max_arrow_width, max_arrow_width]]) + elif where == 'absolute': + orig_position = array([[max_arrow_length/2.0, 3*max_arrow_width]]) + elif where == 'right': + orig_position = array([[length-3*max_arrow_width,\ + 3*max_arrow_width]]) + elif where == 'center': + orig_position = array([[length/2.0, 3*max_arrow_width]]) + else: + raise ValueError, "Got unknown position parameter %s" % where + + + + M = array([[cx, sx],[-sx,cx]]) + coords = dot(orig_position, M) + [[x_pos, y_pos]] + x, y = ravel(coords) + orig_label = rate_labels[pair] + label = '$%s_{_{\mathrm{%s}}}$' % (orig_label[0], orig_label[1:]) + + text(x, y, label, size=label_text_size, ha='center', va='center', \ + color=labelcolor or fc) + + for p in positions.keys(): + draw_arrow(p) + + #test data +all_on_max = dict([(i, 1) for i in 'TCAG'] + \ + [(i+j, 0.6) for i in 'TCAG' for j in 'TCAG']) + +realistic_data = { + 'A':0.4, + 'T':0.3, + 'G':0.5, + 'C':0.2, + 'AT':0.4, + 'AC':0.3, + 'AG':0.2, + 'TA':0.2, + 'TC':0.3, + 'TG':0.4, + 'CT':0.2, + 'CG':0.3, + 'CA':0.2, + 'GA':0.1, + 'GT':0.4, + 'GC':0.1, + } + +extreme_data = { + 'A':0.75, + 'T':0.10, + 'G':0.10, + 'C':0.05, + 'AT':0.6, + 'AC':0.3, + 'AG':0.1, + 'TA':0.02, + 'TC':0.3, + 'TG':0.01, + 'CT':0.2, + 'CG':0.5, + 'CA':0.2, + 'GA':0.1, + 'GT':0.4, + 'GC':0.2, + } + +sample_data = { + 'A':0.2137, + 'T':0.3541, + 'G':0.1946, + 'C':0.2376, + 'AT':0.0228, + 'AC':0.0684, + 'AG':0.2056, + 'TA':0.0315, + 'TC':0.0629, + 'TG':0.0315, + 'CT':0.1355, + 'CG':0.0401, + 'CA':0.0703, + 'GA':0.1824, + 'GT':0.0387, + 'GC':0.1106, + } + + +if __name__ == '__main__': + from sys import argv + d = None + if len(argv) > 1: + if argv[1] == 'full': + d = all_on_max + scaled = False + elif argv[1] == 'extreme': + d = extreme_data + scaled = False + elif argv[1] == 'realistic': + d = realistic_data + scaled = False + elif argv[1] == 'sample': + d = sample_data + scaled = True + if d is None: + d = all_on_max + scaled=False + if len(argv) > 2: + display = argv[2] + else: + display = 'length' + + size = 4 + figure(figsize=(size,size)) + + make_arrow_plot(d, display=display, linewidth=0.001, edgecolor=None, + normalize_data=scaled, head_starts_at_zero=True, size=size) + + draw() + #savefig('arrows.png') + #print 'Example saved to file "arrows.png"' + show() Added: trunk/matplotlib/doc/pyplots/axhspan_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/axhspan_demo.py (rev 0) +++ trunk/matplotlib/doc/pyplots/axhspan_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) @@ -0,0 +1,32 @@ +import numpy as np +import matplotlib.pyplot as plt + +t = np.arange(-1,2, .01) +s = np.sin(2*np.pi*t) + +plt.plot(t,s) +# draw a thick red hline at y=0 that spans the xrange +l = plt.axhline(linewidth=4, color='r') + +# draw a default hline at y=1 that spans the xrange +l = plt.axhline(y=1) + +# draw a default vline at x=1 that spans the xrange +l = plt.axvline(x=1) + +# draw a thick blue vline at x=0 that spans the the upper quadrant of +# the yrange +l = plt.axvline(x=0, ymin=0.75, linewidth=4, color='b') + +# draw a default hline at y=.5 that spans the the middle half of +# the axes +l = plt.axhline(y=.5, xmin=0.25, xmax=0.75) + +p = plt.axhspan(0.25, 0.75, facecolor='0.5', alpha=0.5) + +p = plt.axvspan(1.25, 1.55, facecolor='g', alpha=0.5) + +plt.axis([-1,2,-1,2]) + + +plt.show() Added: trunk/matplotlib/doc/pyplots/bar_stacked.py =================================================================== --- trunk/matplotlib/doc/pyplots/bar_stacked.py (rev 0) +++ trunk/matplotlib/doc/pyplots/bar_stacked.py 2008年06月27日 15:34:32 UTC (rev 5690) @@ -0,0 +1,25 @@ +#!/usr/bin/env python +# a stacked bar plot with errorbars +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 + +p1 = plt.bar(ind, menMeans, width, color='r', yerr=womenStd) +p2 = plt.bar(ind, womenMeans, width, color='y', + bottom=menMeans, yerr=menStd) + +plt.ylabel('Scores') +plt.title('Scores by group and gender') +plt.xticks(ind+width/2., ('G1', 'G2', 'G3', 'G4', 'G5') ) +plt.yticks(np.arange(0,81,10)) +plt.legend( (p1[0], p2[0]), ('Men', 'Women') ) + +plt.show() Added: trunk/matplotlib/doc/pyplots/boxplot_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/boxplot_demo.py (rev 0) +++ trunk/matplotlib/doc/pyplots/boxplot_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) @@ -0,0 +1,145 @@ +import numpy as np +import matplotlib.pyplot as plt + +spread = np.random.rand(50) * 100 +center = np.ones(25) * 50 +flier_high = np.random.rand(10) * 100 + 100 +flier_low = np.random.rand(10) * -100 +data = np.concatenate((spread, center, flier_high, flier_low), 0) + +# fake up some more data +spread = np.random.rand(50) * 100 +center = np.ones(25) * 40 +flier_high = np.random.rand(10) * 100 + 100 +flier_low = np.random.rand(10) * -100 +d2 = np.concatenate( (spread, center, flier_high, flier_low), 0 ) +data.shape = (-1, 1) +d2.shape = (-1, 1) + +#data = concatenate( (data, d2), 1 ) +# Making a 2-D array only works if all the columns are the +# same length. If they are not, then use a list instead. +# This is actually more efficient because boxplot converts +# a 2-D array into a list of vectors internally anyway. +data = [data, d2, d2[::2,0]] +# multiple box plots on one figure + +plt.boxplot(data) +plt.show() + +import numpy as np +import matplotlib.pyplot as plt + +spread = np.random.rand(50) * 100 +center = np.ones(25) * 50 +flier_high = np.random.rand(10) * 100 + 100 +flier_low = np.random.rand(10) * -100 +data = np.concatenate((spread, center, flier_high, flier_low), 0) + +# fake up some more data +spread = np.random.rand(50) * 100 +center = np.ones(25) * 40 +flier_high = np.random.rand(10) * 100 + 100 +flier_low = np.random.rand(10) * -100 +d2 = np.concatenate( (spread, center, flier_high, flier_low), 0 ) +data.shape = (-1, 1) +d2.shape = (-1, 1) + +#data = concatenate( (data, d2), 1 ) +# Making a 2-D array only works if all the columns are the +# same length. If they are not, then use a list instead. +# This is actually more efficient because boxplot converts +# a 2-D array into a list of vectors internally anyway. +data = [data, d2, d2[::2,0]] +# multiple box plots on one figure + +plt.boxplot(data) +plt.show() + +import numpy as np +import matplotlib.pyplot as plt + +spread = np.random.rand(50) * 100 +center = np.ones(25) * 50 +flier_high = np.random.rand(10) * 100 + 100 +flier_low = np.random.rand(10) * -100 +data = np.concatenate((spread, center, flier_high, flier_low), 0) + +# fake up some more data +spread = np.random.rand(50) * 100 +center = np.ones(25) * 40 +flier_high = np.random.rand(10) * 100 + 100 +flier_low = np.random.rand(10) * -100 +d2 = np.concatenate( (spread, center, flier_high, flier_low), 0 ) +data.shape = (-1, 1) +d2.shape = (-1, 1) + +#data = concatenate( (data, d2), 1 ) +# Making a 2-D array only works if all the columns are the +# same length. If they are not, then use a list instead. +# This is actually more efficient because boxplot converts +# a 2-D array into a list of vectors internally anyway. +data = [data, d2, d2[::2,0]] +# multiple box plots on one figure + +plt.boxplot(data) +plt.show() + +import numpy as np +import matplotlib.pyplot as plt + +spread = np.random.rand(50) * 100 +center = np.ones(25) * 50 +flier_high = np.random.rand(10) * 100 + 100 +flier_low = np.random.rand(10) * -100 +data = np.concatenate((spread, center, flier_high, flier_low), 0) + +# fake up some more data +spread = np.random.rand(50) * 100 +center = np.ones(25) * 40 +flier_high = np.random.rand(10) * 100 + 100 +flier_low = np.random.rand(10) * -100 +d2 = np.concatenate( (spread, center, flier_high, flier_low), 0 ) +data.shape = (-1, 1) +d2.shape = (-1, 1) + +#data = concatenate( (data, d2), 1 ) +# Making a 2-D array only works if all the columns are the +# same length. If they are not, then use a list instead. +# This is actually more efficient because boxplot converts +# a 2-D array into a list of vectors internally anyway. +data = [data, d2, d2[::2,0]] +# multiple box plots on one figure + +plt.boxplot(data) +plt.show() + +import numpy as np +import matplotlib.pyplot as plt + +spread = np.random.rand(50) * 100 +center = np.ones(25) * 50 +flier_high = np.random.rand(10) * 100 + 100 +flier_low = np.random.rand(10) * -100 +data = np.concatenate((spread, center, flier_high, flier_low), 0) + +# fake up some more data +spread = np.random.rand(50) * 100 +center = np.ones(25) * 40 +flier_high = np.random.rand(10) * 100 + 100 +flier_low = np.random.rand(10) * -100 +d2 = np.concatenate( (spread, center, flier_high, flier_low), 0 ) +data.shape = (-1, 1) +d2.shape = (-1, 1) + +#data = concatenate( (data, d2), 1 ) +# Making a 2-D array only works if all the columns are the +# same length. If they are not, then use a list instead. +# This is actually more efficient because boxplot converts +# a 2-D array into a list of vectors internally anyway. +data = [data, d2, d2[::2,0]] +# multiple box plots on one figure + +plt.boxplot(data) +plt.show() + Added: trunk/matplotlib/doc/pyplots/broken_barh.py =================================================================== --- trunk/matplotlib/doc/pyplots/broken_barh.py (rev 0) +++ trunk/matplotlib/doc/pyplots/broken_barh.py 2008年06月27日 15:34:32 UTC (rev 5690) @@ -0,0 +1,24 @@ +""" +Make a "broken" horizontal bar plot, ie one with gaps +""" +import matplotlib.pyplot as plt + +fig = plt.figure() +ax = fig.add_subplot(111) +ax.broken_barh([ (110, 30), (150, 10) ] , (10, 9), facecolors='blue') +ax.broken_barh([ (10, 50), (100, 20), (130, 10)] , (20, 9), + facecolors=('red', 'yellow', 'green')) +ax.set_ylim(5,35) +ax.set_xlim(0,200) +ax.set_xlabel('seconds since start') +ax.set_yticks([15,25]) +ax.set_yticklabels(['Bill', 'Jim']) +ax.grid(True) +ax.annotate('race interrupted', (61, 25), + xytext=(0.8, 0.9), textcoords='axes fraction', + arrowprops=dict(facecolor='black', shrink=0.05), + fontsize=16, + horizontalalignment='right', verticalalignment='top') + +#fig.savefig('broken_barh', dpi=100) +plt.show() Added: trunk/matplotlib/doc/pyplots/cohere_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/cohere_demo.py (rev 0) +++ trunk/matplotlib/doc/pyplots/cohere_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) @@ -0,0 +1,36 @@ +#!/usr/bin/env python +""" +Compute the coherence of two signals +""" +import numpy as np +import matplotlib.pyplot as plt + +# make a little extra space between the subplots +plt.subplots_adjust(wspace=0.5) + +dt = 0.01 +t = np.arange(0, 30, dt) +nse1 = np.random.randn(len(t)) # white noise 1 +nse2 = np.random.randn(len(t)) # white noise 2 +r = np.exp(-t/0.05) + +cnse1 = np.convolve(nse1, r, mode='same')*dt # colored noise 1 +cnse2 = np.convolve(nse2, r, mode='same')*dt # colored noise 2 + +# two signals with a coherent part and a random part +s1 = 0.01*np.sin(2*np.pi*10*t) + cnse1 +s2 = 0.01*np.sin(2*np.pi*10*t) + cnse2 + +plt.subplot(211) +plt.plot(t, s1, 'b-', t, s2, 'g-') +plt.xlim(0,5) +plt.xlabel('time') +plt.ylabel('s1 and s2') +plt.grid(True) + +plt.subplot(212) +cxy, f = plt.cohere(s1, s2, 256, 1./dt) +plt.ylabel('coherence') +plt.show() + + Added: trunk/matplotlib/doc/pyplots/contour_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/contour_demo.py (rev 0) +++ trunk/matplotlib/doc/pyplots/contour_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) @@ -0,0 +1,330 @@ +#!/usr/bin/env python +""" +Illustrate simple contour plotting, contours on an image with +a colorbar for the contours, and labelled contours. + +See also contour_image.py. +""" +import matplotlib +import numpy as np +import matplotlib.cm as cm +import matplotlib.mlab as mlab +import matplotlib.pyplot as plt + +matplotlib.rcParams['xtick.direction'] = 'out' +matplotlib.rcParams['ytick.direction'] = 'out' + +delta = 0.025 +x = np.arange(-3.0, 3.0, delta) +y = np.arange(-2.0, 2.0, delta) +X, Y = np.meshgrid(x, y) +Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) +Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1) +# difference of Gaussians +Z = 10.0 * (Z2 - Z1) + + +# You can use a colormap to specify the colors; the default +# colormap will be used for the contour lines +plt.figure() +im = plt.imshow(Z, interpolation='bilinear', origin='lower', + cmap=cm.gray, extent=(-3,3,-2,2)) +levels = np.arange(-1.2, 1.6, 0.2) +CS = plt.contour(Z, levels, + origin='lower', + linewidths=2, + extent=(-3,3,-2,2)) + +#Thicken the zero contour. +zc = CS.collections[6] +plt.setp(zc, linewidth=4) + +plt.clabel(CS, levels[1::2], # label every second level + inline=1, + fmt='%1.1f', + fontsize=14) + +# make a colorbar for the contour lines +CB = plt.colorbar(CS, shrink=0.8, extend='both') + +plt.title('Lines with colorbar') +#plt.hot() # Now change the colormap for the contour lines and colorbar +plt.flag() + +# We can still add a colorbar for the image, too. +CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8) + +# This makes the original colorbar look a bit out of place, +# so let's improve its position. + +l,b,w,h = plt.gca().get_position().bounds +ll,bb,ww,hh = CB.ax.get_position().bounds +CB.ax.set_position([ll, b+0.1*h, ww, h*0.8]) + + +#savefig('contour_demo') +plt.show() +#!/usr/bin/env python +""" +Illustrate simple contour plotting, contours on an image with +a colorbar for the contours, and labelled contours. + +See also contour_image.py. +""" +import matplotlib +import numpy as np +import matplotlib.cm as cm +import matplotlib.mlab as mlab +import matplotlib.pyplot as plt + +matplotlib.rcParams['xtick.direction'] = 'out' +matplotlib.rcParams['ytick.direction'] = 'out' + +delta = 0.025 +x = np.arange(-3.0, 3.0, delta) +y = np.arange(-2.0, 2.0, delta) +X, Y = np.meshgrid(x, y) +Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) +Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1) +# difference of Gaussians +Z = 10.0 * (Z2 - Z1) + + +# You can use a colormap to specify the colors; the default +# colormap will be used for the contour lines +plt.figure() +im = plt.imshow(Z, interpolation='bilinear', origin='lower', + cmap=cm.gray, extent=(-3,3,-2,2)) +levels = np.arange(-1.2, 1.6, 0.2) +CS = plt.contour(Z, levels, + origin='lower', + linewidths=2, + extent=(-3,3,-2,2)) + +#Thicken the zero contour. +zc = CS.collections[6] +plt.setp(zc, linewidth=4) + +plt.clabel(CS, levels[1::2], # label every second level + inline=1, + fmt='%1.1f', + fontsize=14) + +# make a colorbar for the contour lines +CB = plt.colorbar(CS, shrink=0.8, extend='both') + +plt.title('Lines with colorbar') +#plt.hot() # Now change the colormap for the contour lines and colorbar +plt.flag() + +# We can still add a colorbar for the image, too. +CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8) + +# This makes the original colorbar look a bit out of place, +# so let's improve its position. + +l,b,w,h = plt.gca().get_position().bounds +ll,bb,ww,hh = CB.ax.get_position().bounds +CB.ax.set_position([ll, b+0.1*h, ww, h*0.8]) + + +#savefig('contour_demo') +plt.show() +#!/usr/bin/env python +""" +Illustrate simple contour plotting, contours on an image with +a colorbar for the contours, and labelled contours. + +See also contour_image.py. +""" +import matplotlib +import numpy as np +import matplotlib.cm as cm +import matplotlib.mlab as mlab +import matplotlib.pyplot as plt + +matplotlib.rcParams['xtick.direction'] = 'out' +matplotlib.rcParams['ytick.direction'] = 'out' + +delta = 0.025 +x = np.arange(-3.0, 3.0, delta) +y = np.arange(-2.0, 2.0, delta) +X, Y = np.meshgrid(x, y) +Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) +Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1) +# difference of Gaussians +Z = 10.0 * (Z2 - Z1) + + +# You can use a colormap to specify the colors; the default +# colormap will be used for the contour lines +plt.figure() +im = plt.imshow(Z, interpolation='bilinear', origin='lower', + cmap=cm.gray, extent=(-3,3,-2,2)) +levels = np.arange(-1.2, 1.6, 0.2) +CS = plt.contour(Z, levels, + origin='lower', + linewidths=2, + extent=(-3,3,-2,2)) + +#Thicken the zero contour. +zc = CS.collections[6] +plt.setp(zc, linewidth=4) + +plt.clabel(CS, levels[1::2], # label every second level + inline=1, + fmt='%1.1f', + fontsize=14) + +# make a colorbar for the contour lines +CB = plt.colorbar(CS, shrink=0.8, extend='both') + +plt.title('Lines with colorbar') +#plt.hot() # Now change the colormap for the contour lines and colorbar +plt.flag() + +# We can still add a colorbar for the image, too. +CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8) + +# This makes the original colorbar look a bit out of place, +# so let's improve its position. + +l,b,w,h = plt.gca().get_position().bounds +ll,bb,ww,hh = CB.ax.get_position().bounds +CB.ax.set_position([ll, b+0.1*h, ww, h*0.8]) + + +#savefig('contour_demo') +plt.show() +#!/usr/bin/env python +""" +Illustrate simple contour plotting, contours on an image with +a colorbar for the contours, and labelled contours. + +See also contour_image.py. +""" +import matplotlib +import numpy as np +import matplotlib.cm as cm +import matplotlib.mlab as mlab +import matplotlib.pyplot as plt + +matplotlib.rcParams['xtick.direction'] = 'out' +matplotlib.rcParams['ytick.direction'] = 'out' + +delta = 0.025 +x = np.arange(-3.0, 3.0, delta) +y = np.arange(-2.0, 2.0, delta) +X, Y = np.meshgrid(x, y) +Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) +Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1) +# difference of Gaussians +Z = 10.0 * (Z2 - Z1) + + +# You can use a colormap to specify the colors; the default +# colormap will be used for the contour lines +plt.figure() +im = plt.imshow(Z, interpolation='bilinear', origin='lower', + cmap=cm.gray, extent=(-3,3,-2,2)) +levels = np.arange(-1.2, 1.6, 0.2) +CS = plt.contour(Z, levels, + origin='lower', + linewidths=2, + extent=(-3,3,-2,2)) + +#Thicken the zero contour. +zc = CS.collections[6] +plt.setp(zc, linewidth=4) + +plt.clabel(CS, levels[1::2], # label every second level + inline=1, + fmt='%1.1f', + fontsize=14) + +# make a colorbar for the contour lines +CB = plt.colorbar(CS, shrink=0.8, extend='both') + +plt.title('Lines with colorbar') +#plt.hot() # Now change the colormap for the contour lines and colorbar +plt.flag() + +# We can still add a colorbar for the image, too. +CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8) + +# This makes the original colorbar look a bit out of place, +# so let's improve its position. + +l,b,w,h = plt.gca().get_position().bounds +ll,bb,ww,hh = CB.ax.get_position().bounds +CB.ax.set_position([ll, b+0.1*h, ww, h*0.8]) + + +#savefig('contour_demo') +plt.show() +#!/usr/bin/env python +""" +Illustrate simple contour plotting, contours on an image with +a colorbar for the contours, and labelled contours. + +See also contour_image.py. +""" +import matplotlib +import numpy as np +import matplotlib.cm as cm +import matplotlib.mlab as mlab +import matplotlib.pyplot as plt + +matplotlib.rcParams['xtick.direction'] = 'out' +matplotlib.rcParams['ytick.direction'] = 'out' + +delta = 0.025 +x = np.arange(-3.0, 3.0, delta) +y = np.arange(-2.0, 2.0, delta) +X, Y = np.meshgrid(x, y) +Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) +Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1) +# difference of Gaussians +Z = 10.0 * (Z2 - Z1) + + +# You can use a colormap to specify the colors; the default +# colormap will be used for the contour lines +plt.figure() +im = plt.imshow(Z, interpolation='bilinear', origin='lower', + cmap=cm.gray, extent=(-3,3,-2,2)) +levels = np.arange(-1.2, 1.6, 0.2) +CS = plt.contour(Z, levels, + origin='lower', + linewidths=2, + extent=(-3,3,-2,2)) + +#Thicken the zero contour. +zc = CS.collections[6] +plt.setp(zc, linewidth=4) + +plt.clabel(CS, levels[1::2], # label every second level + inline=1, + fmt='%1.1f', + fontsize=14) + +# make a colorbar for the contour lines +CB = plt.colorbar(CS, shrink=0.8, extend='both') + +plt.title('Lines with colorbar') +#plt.hot() # Now change the colormap for the contour lines and colorbar +plt.flag() + +# We can still add a colorbar for the image, too. +CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8) + +# This makes the original colorbar look a bit out of place, +# so let's improve its position. + +l,b,w,h = plt.gca().get_position().bounds +ll,bb,ww,hh = CB.ax.get_position().bounds +CB.ax.set_position([ll, b+0.1*h, ww, h*0.8]) + + +#savefig('contour_demo') +plt.show() Added: trunk/matplotlib/doc/pyplots/csd_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/csd_demo.py (rev 0) +++ trunk/matplotlib/doc/pyplots/csd_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) @@ -0,0 +1,36 @@ +#!/usr/bin/env python +""" +Compute the cross spectral density of two signals +""" +import numpy as np +import matplotlib.pyplot as plt + +# make a little extra space between the subplots +plt.subplots_adjust(wspace=0.5) + +dt = 0.01 +t = np.arange(0, 30, dt) +nse1 = np.random.randn(len(t)) # white noise 1 +nse2 = np.random.randn(len(t)) # white noise 2 +r = np.exp(-t/0.05) + +cnse1 = np.convolve(nse1, r, mode='same')*dt # colored noise 1 +cnse2 = np.convolve(nse2, r, mode='same')*dt # colored noise 2 + +# two signals with a coherent part and a random part +s1 = 0.01*np.sin(2*np.pi*10*t) + cnse1 +s2 = 0.01*np.sin(2*np.pi*10*t) + cnse2 + +plt.subplot(211) +plt.plot(t, s1, 'b-', t, s2, 'g-') +plt.xlim(0,5) +plt.xlabel('time') +plt.ylabel('s1 and s2') +plt.grid(True) + +plt.subplot(212) +cxy, f = plt.csd(s1, s2, 256, 1./dt) +plt.ylabel('CSD (db)') +plt.show() + + Added: trunk/matplotlib/doc/pyplots/errorbar_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/errorbar_demo.py (rev 0) +++ trunk/matplotlib/doc/pyplots/errorbar_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) @@ -0,0 +1,8 @@ +import numpy as np +import matplotlib.pyplot as plt + +t = np.arange(0.1, 4, 0.1) +s = np.exp(-t) +e, f = 0.1*np.absolute(np.random.randn(2, len(s))) +plt.errorbar(t, s, e, fmt='o') # vertical symmetric +plt.show() Added: trunk/matplotlib/doc/pyplots/figimage_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/figimage_demo.py (rev 0) +++ trunk/matplotlib/doc/pyplots/figimage_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) @@ -0,0 +1,21 @@ +""" +See pcolor_demo2 for a much faster way of generating pcolor plots +""" +import numpy as np +import matplotlib +import matplotlib.cm as cm +import matplotlib.pyplot as plt + + +fig = plt.figure(frameon=False) +Z = np.arange(10000.0) +Z.shape = 100,100 +Z[:,50:] = 1. + +im1 = plt.figimage(Z, xo=50, yo=0, cmap=cm.jet) +im2 = plt.figimage(Z, xo=100, yo=100, alpha=.8, cmap=cm.jet) + +plt.show() + + + Added: trunk/matplotlib/doc/pyplots/figlegend_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/figlegend_demo.py (rev 0) +++ trunk/matplotlib/doc/pyplots/figlegend_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) @@ -0,0 +1,19 @@ +import numpy as np +import matplotlib.pyplot as plt + +fig = plt.figure() +ax1 = fig.add_axes([0.1, 0.1, 0.4, 0.7]) +ax2 = fig.add_axes([0.55, 0.1, 0.4, 0.7]) + +x = np.arange(0.0, 2.0, 0.02) +y1 = np.sin(2*np.pi*x) +y2 = np.exp(-x) +l1, l2 = ax1.plot(x, y1, 'rs-', x, y2, 'go') + +y3 = np.sin(4*np.pi*x) +y4 = np.exp(-2*x) +l3, l4 = ax2.plot(x, y3, 'yd-', x, y3, 'k^') + +fig.legend((l1, l2), ('Line 1', 'Line 2'), 'upper left') +fig.legend((l3, l4), ('Line 3', 'Line 4'), 'upper right') +plt.show() Added: trunk/matplotlib/doc/pyplots/fill_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/fill_demo.py (rev 0) +++ trunk/matplotlib/doc/pyplots/fill_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) @@ -0,0 +1,10 @@ +#!/usr/bin/env python +import numpy as np +import matplotlib.pyplot as plt + +t = np.arange(0.0, 1.01, 0.01) +s = np.sin(2*2*np.pi*t) + +plt.fill(t, s*np.exp(-5*t), 'r') +plt.grid(True) +plt.show() Added: trunk/matplotlib/doc/pyplots/hexbin_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/hexbin_demo.py (rev 0) +++ trunk/matplotlib/doc/pyplots/hexbin_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) @@ -0,0 +1,34 @@ +""" +hexbin is an axes method or pyplot function that is essentially +a pcolor of a 2-D histogram with hexagonal cells. It can be +much more informative than a scatter plot; in the first subplot +below, try substituting 'scatter' for 'hexbin'. +""" + +import numpy as np +import matplotlib.pyplot as plt +n = 100000 +x = np.random.standard_normal(n) +y = 2.0 + 3.0 * x + 4.0 * np.random.standard_normal(n) +xmin = x.min() +xmax = x.max() +ymin = y.min() +ymax = y.max() + +plt.subplots_adjust(hspace=0.5) +plt.subplot(121) +plt.hexbin(x,y) +plt.axis([xmin, xmax, ymin, ymax]) +plt.title("Hexagon binning") +cb = plt.colorbar() +cb.set_label('counts') + +plt.subplot(122) +plt.hexbin(x,y,bins='log') +plt.axis([xmin, xmax, ymin, ymax]) +plt.title("With a log color scale") +cb = plt.colorbar() +cb.set_label('log10(N)') + +plt.show() + Added: trunk/matplotlib/doc/pyplots/histogram_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/histogram_demo.py (rev 0) +++ trunk/matplotlib/doc/pyplots/histogram_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) @@ -0,0 +1,22 @@ +#!/usr/bin/env python +import numpy as np +import matplotlib.mlab as mlab +import matplotlib.pyplot as plt + +mu, sigma = 100, 15 +x = mu + sigma*np.random.randn(10000) + +# the histogram of the data +n, bins, patches = plt.hist(x, 50, normed=1, facecolor='green', alpha=0.75) + +# add a 'best fit' line +y = mlab.normpdf( bins, mu, sigma) +l = plt.plot(bins, y, 'r--', linewidth=1) + +plt.xlabel('Smarts') +plt.ylabel('Probability') +plt.title(r'$\mathrm{Histogram\ of\ IQ:}\ \mu=100,\ \sigma=15$') +plt.axis([40, 160, 0, 0.03]) +plt.grid(True) + +plt.show() Added: trunk/matplotlib/doc/pyplots/hline_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/hline_demo.py (rev 0) +++ trunk/matplotlib/doc/pyplots/hline_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) @@ -0,0 +1,23 @@ +#!/usr/bin/env python +import numpy as np +import matplotlib.pyplot as plt + +def f(t): + s1 = np.sin(2*np.pi*t) + e1 = np.exp(-t) + return np.absolute((s1*e1))+.05 + + +t = np.arange(0.0, 5.0, 0.1) +s = f(t) +nse = np.random.normal(0.0, 0.3, t.shape) * s + + +plt.plot(s+nse, t, 'b^') +plt.hlines(t, [0], s, lw=2) +plt.xlabel('time (s)') +plt.title('Comparison of model with data') +plt.savefig('test') +plt.xlim(xmin=0) +plt.show() + Added: trunk/matplotlib/doc/pyplots/image_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/image_demo.py (rev 0) +++ trunk/matplotlib/doc/pyplots/image_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) @@ -0,0 +1,18 @@ +#!/usr/bin/env python +import numpy as np +import matplotlib.cm as cm +import matplotlib.mlab as mlab +import matplotlib.pyplot as plt + +delta = 0.025 +x = y = np.arange(-3.0, 3.0, delta) +X, Y = np.meshgrid(x, y) +Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) +Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1) +Z = Z2-Z1 # difference of Gaussians + +im = plt.imshow(Z, interpolation='bilinear', cmap=cm.gray, + origin='lower', extent=[-3,3,-3,3]) + +plt.show() + Added: trunk/matplotlib/doc/pyplots/log_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/log_demo.py (rev 0) +++ trunk/matplotlib/doc/pyplots/log_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) @@ -0,0 +1,25 @@ +import numpy as np +import matplotlib.pyplot as plt + +plt.subplots_adjust(hspace=0.4) +t = np.arange(0.01, 20.0, 0.01) + +# log y axis +plt.subplot(311) +plt.semilogy(t, np.exp(-t/5.0)) +plt.ylabel('semilogy') +plt.grid(True) + +# log x axis +plt.subplot(312) +plt.semilogx(t, np.sin(2*np.pi*t)) +plt.ylabel('semilogx') +plt.grid(True) + +# log x and y axis +plt.subplot(313) +plt.loglog(t, 20*np.exp(-t/10.0), basex=4) +plt.grid(True) +plt.ylabel('loglog base 4 on x') + +plt.show() Added: trunk/matplotlib/doc/pyplots/xcorr_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/xcorr_demo.py (rev 0) +++ trunk/matplotlib/doc/pyplots/xcorr_demo.py 2008年06月27日 15:34:32 UTC (rev 5690) @@ -0,0 +1,17 @@ +import matplotlib.pyplot as plt +import numpy as np + +x,y = np.random.randn(2,100) +fig = plt.figure() +ax1 = fig.add_subplot(211) +ax1.xcorr(x, y, usevlines=True, maxlags=50, normed=True, lw=2) +ax1.grid(True) +ax1.axhline(0, color='black', lw=2) + +ax2 = fig.add_subplot(212, sharex=ax1) +ax2.acorr(x, usevlines=True, normed=True, maxlags=50, lw=2) +ax2.grid(True) +ax2.axhline(0, color='black', lw=2) + +plt.show() + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5693 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5693&view=rev Author: jdh2358 Date: 2008年06月27日 08:42:44 -0700 (2008年6月27日) Log Message: ----------- cleaned up some pyplots examples that got funkily duplicated Modified Paths: -------------- trunk/matplotlib/doc/pyplots/boxplot_demo.py trunk/matplotlib/doc/pyplots/contour_demo.py Modified: trunk/matplotlib/doc/pyplots/boxplot_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/boxplot_demo.py 2008年06月27日 15:40:06 UTC (rev 5692) +++ trunk/matplotlib/doc/pyplots/boxplot_demo.py 2008年06月27日 15:42:44 UTC (rev 5693) @@ -27,119 +27,3 @@ plt.boxplot(data) plt.show() -import numpy as np -import matplotlib.pyplot as plt - -spread = np.random.rand(50) * 100 -center = np.ones(25) * 50 -flier_high = np.random.rand(10) * 100 + 100 -flier_low = np.random.rand(10) * -100 -data = np.concatenate((spread, center, flier_high, flier_low), 0) - -# fake up some more data -spread = np.random.rand(50) * 100 -center = np.ones(25) * 40 -flier_high = np.random.rand(10) * 100 + 100 -flier_low = np.random.rand(10) * -100 -d2 = np.concatenate( (spread, center, flier_high, flier_low), 0 ) -data.shape = (-1, 1) -d2.shape = (-1, 1) - -#data = concatenate( (data, d2), 1 ) -# Making a 2-D array only works if all the columns are the -# same length. If they are not, then use a list instead. -# This is actually more efficient because boxplot converts -# a 2-D array into a list of vectors internally anyway. -data = [data, d2, d2[::2,0]] -# multiple box plots on one figure - -plt.boxplot(data) -plt.show() - -import numpy as np -import matplotlib.pyplot as plt - -spread = np.random.rand(50) * 100 -center = np.ones(25) * 50 -flier_high = np.random.rand(10) * 100 + 100 -flier_low = np.random.rand(10) * -100 -data = np.concatenate((spread, center, flier_high, flier_low), 0) - -# fake up some more data -spread = np.random.rand(50) * 100 -center = np.ones(25) * 40 -flier_high = np.random.rand(10) * 100 + 100 -flier_low = np.random.rand(10) * -100 -d2 = np.concatenate( (spread, center, flier_high, flier_low), 0 ) -data.shape = (-1, 1) -d2.shape = (-1, 1) - -#data = concatenate( (data, d2), 1 ) -# Making a 2-D array only works if all the columns are the -# same length. If they are not, then use a list instead. -# This is actually more efficient because boxplot converts -# a 2-D array into a list of vectors internally anyway. -data = [data, d2, d2[::2,0]] -# multiple box plots on one figure - -plt.boxplot(data) -plt.show() - -import numpy as np -import matplotlib.pyplot as plt - -spread = np.random.rand(50) * 100 -center = np.ones(25) * 50 -flier_high = np.random.rand(10) * 100 + 100 -flier_low = np.random.rand(10) * -100 -data = np.concatenate((spread, center, flier_high, flier_low), 0) - -# fake up some more data -spread = np.random.rand(50) * 100 -center = np.ones(25) * 40 -flier_high = np.random.rand(10) * 100 + 100 -flier_low = np.random.rand(10) * -100 -d2 = np.concatenate( (spread, center, flier_high, flier_low), 0 ) -data.shape = (-1, 1) -d2.shape = (-1, 1) - -#data = concatenate( (data, d2), 1 ) -# Making a 2-D array only works if all the columns are the -# same length. If they are not, then use a list instead. -# This is actually more efficient because boxplot converts -# a 2-D array into a list of vectors internally anyway. -data = [data, d2, d2[::2,0]] -# multiple box plots on one figure - -plt.boxplot(data) -plt.show() - -import numpy as np -import matplotlib.pyplot as plt - -spread = np.random.rand(50) * 100 -center = np.ones(25) * 50 -flier_high = np.random.rand(10) * 100 + 100 -flier_low = np.random.rand(10) * -100 -data = np.concatenate((spread, center, flier_high, flier_low), 0) - -# fake up some more data -spread = np.random.rand(50) * 100 -center = np.ones(25) * 40 -flier_high = np.random.rand(10) * 100 + 100 -flier_low = np.random.rand(10) * -100 -d2 = np.concatenate( (spread, center, flier_high, flier_low), 0 ) -data.shape = (-1, 1) -d2.shape = (-1, 1) - -#data = concatenate( (data, d2), 1 ) -# Making a 2-D array only works if all the columns are the -# same length. If they are not, then use a list instead. -# This is actually more efficient because boxplot converts -# a 2-D array into a list of vectors internally anyway. -data = [data, d2, d2[::2,0]] -# multiple box plots on one figure - -plt.boxplot(data) -plt.show() - Modified: trunk/matplotlib/doc/pyplots/contour_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/contour_demo.py 2008年06月27日 15:40:06 UTC (rev 5692) +++ trunk/matplotlib/doc/pyplots/contour_demo.py 2008年06月27日 15:42:44 UTC (rev 5693) @@ -64,267 +64,3 @@ #savefig('contour_demo') plt.show() -#!/usr/bin/env python -""" -Illustrate simple contour plotting, contours on an image with -a colorbar for the contours, and labelled contours. - -See also contour_image.py. -""" -import matplotlib -import numpy as np -import matplotlib.cm as cm -import matplotlib.mlab as mlab -import matplotlib.pyplot as plt - -matplotlib.rcParams['xtick.direction'] = 'out' -matplotlib.rcParams['ytick.direction'] = 'out' - -delta = 0.025 -x = np.arange(-3.0, 3.0, delta) -y = np.arange(-2.0, 2.0, delta) -X, Y = np.meshgrid(x, y) -Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) -Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1) -# difference of Gaussians -Z = 10.0 * (Z2 - Z1) - - -# You can use a colormap to specify the colors; the default -# colormap will be used for the contour lines -plt.figure() -im = plt.imshow(Z, interpolation='bilinear', origin='lower', - cmap=cm.gray, extent=(-3,3,-2,2)) -levels = np.arange(-1.2, 1.6, 0.2) -CS = plt.contour(Z, levels, - origin='lower', - linewidths=2, - extent=(-3,3,-2,2)) - -#Thicken the zero contour. -zc = CS.collections[6] -plt.setp(zc, linewidth=4) - -plt.clabel(CS, levels[1::2], # label every second level - inline=1, - fmt='%1.1f', - fontsize=14) - -# make a colorbar for the contour lines -CB = plt.colorbar(CS, shrink=0.8, extend='both') - -plt.title('Lines with colorbar') -#plt.hot() # Now change the colormap for the contour lines and colorbar -plt.flag() - -# We can still add a colorbar for the image, too. -CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8) - -# This makes the original colorbar look a bit out of place, -# so let's improve its position. - -l,b,w,h = plt.gca().get_position().bounds -ll,bb,ww,hh = CB.ax.get_position().bounds -CB.ax.set_position([ll, b+0.1*h, ww, h*0.8]) - - -#savefig('contour_demo') -plt.show() -#!/usr/bin/env python -""" -Illustrate simple contour plotting, contours on an image with -a colorbar for the contours, and labelled contours. - -See also contour_image.py. -""" -import matplotlib -import numpy as np -import matplotlib.cm as cm -import matplotlib.mlab as mlab -import matplotlib.pyplot as plt - -matplotlib.rcParams['xtick.direction'] = 'out' -matplotlib.rcParams['ytick.direction'] = 'out' - -delta = 0.025 -x = np.arange(-3.0, 3.0, delta) -y = np.arange(-2.0, 2.0, delta) -X, Y = np.meshgrid(x, y) -Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) -Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1) -# difference of Gaussians -Z = 10.0 * (Z2 - Z1) - - -# You can use a colormap to specify the colors; the default -# colormap will be used for the contour lines -plt.figure() -im = plt.imshow(Z, interpolation='bilinear', origin='lower', - cmap=cm.gray, extent=(-3,3,-2,2)) -levels = np.arange(-1.2, 1.6, 0.2) -CS = plt.contour(Z, levels, - origin='lower', - linewidths=2, - extent=(-3,3,-2,2)) - -#Thicken the zero contour. -zc = CS.collections[6] -plt.setp(zc, linewidth=4) - -plt.clabel(CS, levels[1::2], # label every second level - inline=1, - fmt='%1.1f', - fontsize=14) - -# make a colorbar for the contour lines -CB = plt.colorbar(CS, shrink=0.8, extend='both') - -plt.title('Lines with colorbar') -#plt.hot() # Now change the colormap for the contour lines and colorbar -plt.flag() - -# We can still add a colorbar for the image, too. -CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8) - -# This makes the original colorbar look a bit out of place, -# so let's improve its position. - -l,b,w,h = plt.gca().get_position().bounds -ll,bb,ww,hh = CB.ax.get_position().bounds -CB.ax.set_position([ll, b+0.1*h, ww, h*0.8]) - - -#savefig('contour_demo') -plt.show() -#!/usr/bin/env python -""" -Illustrate simple contour plotting, contours on an image with -a colorbar for the contours, and labelled contours. - -See also contour_image.py. -""" -import matplotlib -import numpy as np -import matplotlib.cm as cm -import matplotlib.mlab as mlab -import matplotlib.pyplot as plt - -matplotlib.rcParams['xtick.direction'] = 'out' -matplotlib.rcParams['ytick.direction'] = 'out' - -delta = 0.025 -x = np.arange(-3.0, 3.0, delta) -y = np.arange(-2.0, 2.0, delta) -X, Y = np.meshgrid(x, y) -Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) -Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1) -# difference of Gaussians -Z = 10.0 * (Z2 - Z1) - - -# You can use a colormap to specify the colors; the default -# colormap will be used for the contour lines -plt.figure() -im = plt.imshow(Z, interpolation='bilinear', origin='lower', - cmap=cm.gray, extent=(-3,3,-2,2)) -levels = np.arange(-1.2, 1.6, 0.2) -CS = plt.contour(Z, levels, - origin='lower', - linewidths=2, - extent=(-3,3,-2,2)) - -#Thicken the zero contour. -zc = CS.collections[6] -plt.setp(zc, linewidth=4) - -plt.clabel(CS, levels[1::2], # label every second level - inline=1, - fmt='%1.1f', - fontsize=14) - -# make a colorbar for the contour lines -CB = plt.colorbar(CS, shrink=0.8, extend='both') - -plt.title('Lines with colorbar') -#plt.hot() # Now change the colormap for the contour lines and colorbar -plt.flag() - -# We can still add a colorbar for the image, too. -CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8) - -# This makes the original colorbar look a bit out of place, -# so let's improve its position. - -l,b,w,h = plt.gca().get_position().bounds -ll,bb,ww,hh = CB.ax.get_position().bounds -CB.ax.set_position([ll, b+0.1*h, ww, h*0.8]) - - -#savefig('contour_demo') -plt.show() -#!/usr/bin/env python -""" -Illustrate simple contour plotting, contours on an image with -a colorbar for the contours, and labelled contours. - -See also contour_image.py. -""" -import matplotlib -import numpy as np -import matplotlib.cm as cm -import matplotlib.mlab as mlab -import matplotlib.pyplot as plt - -matplotlib.rcParams['xtick.direction'] = 'out' -matplotlib.rcParams['ytick.direction'] = 'out' - -delta = 0.025 -x = np.arange(-3.0, 3.0, delta) -y = np.arange(-2.0, 2.0, delta) -X, Y = np.meshgrid(x, y) -Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) -Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1) -# difference of Gaussians -Z = 10.0 * (Z2 - Z1) - - -# You can use a colormap to specify the colors; the default -# colormap will be used for the contour lines -plt.figure() -im = plt.imshow(Z, interpolation='bilinear', origin='lower', - cmap=cm.gray, extent=(-3,3,-2,2)) -levels = np.arange(-1.2, 1.6, 0.2) -CS = plt.contour(Z, levels, - origin='lower', - linewidths=2, - extent=(-3,3,-2,2)) - -#Thicken the zero contour. -zc = CS.collections[6] -plt.setp(zc, linewidth=4) - -plt.clabel(CS, levels[1::2], # label every second level - inline=1, - fmt='%1.1f', - fontsize=14) - -# make a colorbar for the contour lines -CB = plt.colorbar(CS, shrink=0.8, extend='both') - -plt.title('Lines with colorbar') -#plt.hot() # Now change the colormap for the contour lines and colorbar -plt.flag() - -# We can still add a colorbar for the image, too. -CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8) - -# This makes the original colorbar look a bit out of place, -# so let's improve its position. - -l,b,w,h = plt.gca().get_position().bounds -ll,bb,ww,hh = CB.ax.get_position().bounds -CB.ax.set_position([ll, b+0.1*h, ww, h*0.8]) - - -#savefig('contour_demo') -plt.show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5692 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5692&view=rev Author: jdh2358 Date: 2008年06月27日 08:40:06 -0700 (2008年6月27日) Log Message: ----------- removing the copied files I accidentally added (sigh). It is confusing to put autogenerated files next to legit files in pyplot... Removed Paths: ------------- trunk/matplotlib/doc/pyplots/hline_demo.py Deleted: trunk/matplotlib/doc/pyplots/hline_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/hline_demo.py 2008年06月27日 15:39:28 UTC (rev 5691) +++ trunk/matplotlib/doc/pyplots/hline_demo.py 2008年06月27日 15:40:06 UTC (rev 5692) @@ -1,23 +0,0 @@ -#!/usr/bin/env python -import numpy as np -import matplotlib.pyplot as plt - -def f(t): - s1 = np.sin(2*np.pi*t) - e1 = np.exp(-t) - return np.absolute((s1*e1))+.05 - - -t = np.arange(0.0, 5.0, 0.1) -s = f(t) -nse = np.random.normal(0.0, 0.3, t.shape) * s - - -plt.plot(s+nse, t, 'b^') -plt.hlines(t, [0], s, lw=2) -plt.xlabel('time (s)') -plt.title('Comparison of model with data') -plt.savefig('test') -plt.xlim(xmin=0) -plt.show() - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5688 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5688&view=rev Author: jdh2358 Date: 2008年06月27日 08:25:50 -0700 (2008年6月27日) Log Message: ----------- more doc examples and cleanups Modified Paths: -------------- trunk/matplotlib/examples/pylab_examples/axhspan_demo.py trunk/matplotlib/examples/pylab_examples/barchart_demo.py trunk/matplotlib/examples/pylab_examples/contour_demo.py trunk/matplotlib/examples/pylab_examples/figimage_demo.py trunk/matplotlib/examples/pylab_examples/figlegend_demo.py trunk/matplotlib/examples/pylab_examples/log_demo.py trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/contour.py trunk/matplotlib/lib/matplotlib/figure.py Modified: trunk/matplotlib/examples/pylab_examples/axhspan_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/axhspan_demo.py 2008年06月27日 13:33:33 UTC (rev 5687) +++ trunk/matplotlib/examples/pylab_examples/axhspan_demo.py 2008年06月27日 15:25:50 UTC (rev 5688) @@ -1,40 +1,32 @@ -#!/usr/bin/env python +import numpy as np +import matplotlib.pyplot as plt -from pylab import * -figure(1) -plot(10*rand(12), 'o') -xlim(0,15) -xticks([2, 4, 8, 12], ('John', 'Hunter', 'Was', 'Here')) +t = np.arange(-1,2, .01) +s = np.sin(2*np.pi*t) -ylim(-1,10) -yticks(range(8)) - -figure(2) -t = arange(-1,2, .01) -s = sin(2*pi*t) -plot(t,s) +plt.plot(t,s) # draw a thick red hline at y=0 that spans the xrange -l = axhline(linewidth=4, color='r') +l = plt.axhline(linewidth=4, color='r') # draw a default hline at y=1 that spans the xrange -l = axhline(y=1) +l = plt.axhline(y=1) # draw a default vline at x=1 that spans the xrange -l = axvline(x=1) +l = plt.axvline(x=1) # draw a thick blue vline at x=0 that spans the the upper quadrant of # the yrange -l = axvline(x=0, ymin=0.75, linewidth=4, color='b') +l = plt.axvline(x=0, ymin=0.75, linewidth=4, color='b') # draw a default hline at y=.5 that spans the the middle half of # the axes -l = axhline(y=.5, xmin=0.25, xmax=0.75) +l = plt.axhline(y=.5, xmin=0.25, xmax=0.75) -p = axhspan(0.25, 0.75, facecolor='0.5', alpha=0.5) +p = plt.axhspan(0.25, 0.75, facecolor='0.5', alpha=0.5) -p = axvspan(1.25, 1.55, facecolor='g', alpha=0.5) +p = plt.axvspan(1.25, 1.55, facecolor='g', alpha=0.5) -axis([-1,2,-1,2]) +plt.axis([-1,2,-1,2]) -show() +plt.show() Modified: trunk/matplotlib/examples/pylab_examples/barchart_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/barchart_demo.py 2008年06月27日 13:33:33 UTC (rev 5687) +++ trunk/matplotlib/examples/pylab_examples/barchart_demo.py 2008年06月27日 15:25:50 UTC (rev 5688) @@ -1,39 +1,38 @@ #!/usr/bin/env python -# a bar plot with errorbars -from numpy import arange -from matplotlib.pyplot import * +import numpy as np +import matplotlib.pyplot as plt N = 5 menMeans = (20, 35, 30, 35, 27) menStd = (2, 3, 4, 1, 2) -ind = arange(N) # the x locations for the groups +ind = np.arange(N) # the x locations for the groups width = 0.35 # the width of the bars -figure() -subplot(111) -rects1 = bar(ind, menMeans, width, color='r', yerr=menStd) +plt.subplot(111) +rects1 = plt.bar(ind, menMeans, width, color='r', yerr=menStd) + womenMeans = (25, 32, 34, 20, 25) womenStd = (3, 5, 2, 3, 3) -rects2 = bar(ind+width, womenMeans, width, color='y', yerr=womenStd) +rects2 = plt.bar(ind+width, womenMeans, width, color='y', yerr=womenStd) # add some -ylabel('Scores') -title('Scores by group and gender') -xticks(ind+width, ('G1', 'G2', 'G3', 'G4', 'G5') ) +plt.ylabel('Scores') +plt.title('Scores by group and gender') +plt.xticks(ind+width, ('G1', 'G2', 'G3', 'G4', 'G5') ) -legend( (rects1[0], rects2[0]), ('Men', 'Women') ) +plt.legend( (rects1[0], rects2[0]), ('Men', 'Women') ) def autolabel(rects): # attach some text labels for rect in rects: height = rect.get_height() - text(rect.get_x()+rect.get_width()/2., 1.05*height, '%d'%int(height), + plt.text(rect.get_x()+rect.get_width()/2., 1.05*height, '%d'%int(height), ha='center', va='bottom') autolabel(rects1) autolabel(rects2) #savefig('barchart_demo') -show() +plt.show() Modified: trunk/matplotlib/examples/pylab_examples/contour_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/contour_demo.py 2008年06月27日 13:33:33 UTC (rev 5687) +++ trunk/matplotlib/examples/pylab_examples/contour_demo.py 2008年06月27日 15:25:50 UTC (rev 5688) @@ -1,21 +1,25 @@ #!/usr/bin/env python -''' +""" Illustrate simple contour plotting, contours on an image with a colorbar for the contours, and labelled contours. See also contour_image.py. -''' -from pylab import * +""" +import matplotlib +import numpy as np +import matplotlib.cm as cm +import matplotlib.mlab as mlab +import matplotlib.pyplot as plt -rcParams['xtick.direction'] = 'out' -rcParams['ytick.direction'] = 'out' +matplotlib.rcParams['xtick.direction'] = 'out' +matplotlib.rcParams['ytick.direction'] = 'out' delta = 0.025 -x = arange(-3.0, 3.0, delta) -y = arange(-2.0, 2.0, delta) -X, Y = meshgrid(x, y) -Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) -Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1) +x = np.arange(-3.0, 3.0, delta) +y = np.arange(-2.0, 2.0, delta) +X, Y = np.meshgrid(x, y) +Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) +Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1) # difference of Gaussians Z = 10.0 * (Z2 - Z1) @@ -25,77 +29,77 @@ # inline argument to clabel will control whether the labels are draw # over the line segments of the contour, removing the lines beneath # the label -figure() -CS = contour(X, Y, Z) -clabel(CS, inline=1, fontsize=10) -title('Simplest default with labels') +plt.figure() +CS = plt.contour(X, Y, Z) +plt.clabel(CS, inline=1, fontsize=10) +plt.title('Simplest default with labels') # You can force all the contours to be the same color. -figure() -CS = contour(X, Y, Z, 6, - colors='k', # negative contours will be dashed by default - ) -clabel(CS, fontsize=9, inline=1) -title('Single color - negative contours dashed') +plt.figure() +CS = plt.contour(X, Y, Z, 6, + colors='k', # negative contours will be dashed by default + ) +plt.clabel(CS, fontsize=9, inline=1) +plt.title('Single color - negative contours dashed') # You can set negative contours to be solid instead of dashed: -rcParams['contour.negative_linestyle'] = 'solid' -figure() -CS = contour(X, Y, Z, 6, - colors='k', # negative contours will be dashed by default - ) -clabel(CS, fontsize=9, inline=1) -title('Single color - negative contours solid') +matplotlib.rcParams['contour.negative_linestyle'] = 'solid' +plt.figure() +CS = plt.contour(X, Y, Z, 6, + colors='k', # negative contours will be dashed by default + ) +plt.clabel(CS, fontsize=9, inline=1) +plt.title('Single color - negative contours solid') # And you can manually specify the colors of the contour -figure() -CS = contour(X, Y, Z, 6, - linewidths=arange(.5, 4, .5), - colors=('r', 'green', 'blue', (1,1,0), '#afeeee', '0.5') - ) -clabel(CS, fontsize=9, inline=1) -title('Crazy lines') +plt.figure() +CS = plt.contour(X, Y, Z, 6, + linewidths=np.arange(.5, 4, .5), + colors=('r', 'green', 'blue', (1,1,0), '#afeeee', '0.5') + ) +plt.clabel(CS, fontsize=9, inline=1) +plt.title('Crazy lines') # Or you can use a colormap to specify the colors; the default # colormap will be used for the contour lines -figure() -im = imshow(Z, interpolation='bilinear', origin='lower', - cmap=cm.gray, extent=(-3,3,-2,2)) -levels = arange(-1.2, 1.6, 0.2) -CS = contour(Z, levels, - origin='lower', - linewidths=2, - extent=(-3,3,-2,2)) +plt.figure() +im = plt.imshow(Z, interpolation='bilinear', origin='lower', + cmap=cm.gray, extent=(-3,3,-2,2)) +levels = np.arange(-1.2, 1.6, 0.2) +CS = plt.contour(Z, levels, + origin='lower', + linewidths=2, + extent=(-3,3,-2,2)) #Thicken the zero contour. zc = CS.collections[6] -setp(zc, linewidth=4) +plt.setp(zc, linewidth=4) -clabel(CS, levels[1::2], # label every second level - inline=1, - fmt='%1.1f', - fontsize=14) +plt.clabel(CS, levels[1::2], # label every second level + inline=1, + fmt='%1.1f', + fontsize=14) # make a colorbar for the contour lines -CB = colorbar(CS, shrink=0.8, extend='both') +CB = plt.colorbar(CS, shrink=0.8, extend='both') -title('Lines with colorbar') -hot() # Now change the colormap for the contour lines and colorbar -flag() +plt.title('Lines with colorbar') +#plt.hot() # Now change the colormap for the contour lines and colorbar +plt.flag() # We can still add a colorbar for the image, too. -CBI = colorbar(im, orientation='horizontal', shrink=0.8) +CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8) # This makes the original colorbar look a bit out of place, # so let's improve its position. -l,b,w,h = gca().get_position().bounds +l,b,w,h = plt.gca().get_position().bounds ll,bb,ww,hh = CB.ax.get_position().bounds CB.ax.set_position([ll, b+0.1*h, ww, h*0.8]) #savefig('contour_demo') -show() +plt.show() Modified: trunk/matplotlib/examples/pylab_examples/figimage_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/figimage_demo.py 2008年06月27日 13:33:33 UTC (rev 5687) +++ trunk/matplotlib/examples/pylab_examples/figimage_demo.py 2008年06月27日 15:25:50 UTC (rev 5688) @@ -1,21 +1,21 @@ -#!/usr/bin/env python """ See pcolor_demo2 for a much faster way of generating pcolor plots """ -from __future__ import division -from pylab import * -rc('axes', hold=True) -rc('image', origin='upper') -figure(1, frameon=False) -Z = arange(10000.0); Z.shape = 100,100 -Z[:,50:] = 1 -jet() # sets the default -im1 = figimage(Z, xo=50, yo=0) -im2 = figimage(Z, xo=100, yo=100, alpha=.8) -#gray() # overrides current and sets default -#savefig('figimage_demo') +import numpy as np +import matplotlib +import matplotlib.cm as cm +import matplotlib.pyplot as plt -show() +fig = plt.figure(frameon=False) +Z = np.arange(10000.0) +Z.shape = 100,100 +Z[:,50:] = 1. +im1 = plt.figimage(Z, xo=50, yo=0, cmap=cm.jet) +im2 = plt.figimage(Z, xo=100, yo=100, alpha=.8, cmap=cm.jet) +plt.show() + + + Modified: trunk/matplotlib/examples/pylab_examples/figlegend_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/figlegend_demo.py 2008年06月27日 13:33:33 UTC (rev 5687) +++ trunk/matplotlib/examples/pylab_examples/figlegend_demo.py 2008年06月27日 15:25:50 UTC (rev 5688) @@ -1,18 +1,19 @@ -#!/usr/bin/env python +import numpy as np +import matplotlib.pyplot as plt -from pylab import * -ax1 = axes([0.1, 0.1, 0.4, 0.7]) -ax2 = axes([0.55, 0.1, 0.4, 0.7]) +fig = plt.figure() +ax1 = fig.add_axes([0.1, 0.1, 0.4, 0.7]) +ax2 = fig.add_axes([0.55, 0.1, 0.4, 0.7]) -x = arange(0.0, 2.0, 0.02) -y1 = sin(2*pi*x) -y2 = exp(-x) +x = np.arange(0.0, 2.0, 0.02) +y1 = np.sin(2*np.pi*x) +y2 = np.exp(-x) l1, l2 = ax1.plot(x, y1, 'rs-', x, y2, 'go') -y3 = sin(4*pi*x) -y4 = exp(-2*x) +y3 = np.sin(4*np.pi*x) +y4 = np.exp(-2*x) l3, l4 = ax2.plot(x, y3, 'yd-', x, y3, 'k^') -figlegend((l1, l2), ('Line 1', 'Line 2'), 'upper left') -figlegend((l3, l4), ('Line 3', 'Line 4'), 'upper right') -show() +fig.legend((l1, l2), ('Line 1', 'Line 2'), 'upper left') +fig.legend((l3, l4), ('Line 3', 'Line 4'), 'upper right') +plt.show() Modified: trunk/matplotlib/examples/pylab_examples/log_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/log_demo.py 2008年06月27日 13:33:33 UTC (rev 5687) +++ trunk/matplotlib/examples/pylab_examples/log_demo.py 2008年06月27日 15:25:50 UTC (rev 5688) @@ -1,26 +1,25 @@ -#!/usr/bin/env python -from pylab import * +import numpy as np +import matplotlib.pyplot as plt -dt = 0.01 -t = arange(dt, 20.0, dt) +plt.subplots_adjust(hspace=0.4) +t = np.arange(0.01, 20.0, 0.01) -subplot(311) -semilogy(t, exp(-t/5.0)) -ylabel('semilogy') -grid(True) +# log y axis +plt.subplot(311) +plt.semilogy(t, np.exp(-t/5.0)) +plt.ylabel('semilogy') +plt.grid(True) -subplot(312) -semilogx(t, sin(2*pi*t)) -ylabel('semilogx') +# log x axis +plt.subplot(312) +plt.semilogx(t, np.sin(2*np.pi*t)) +plt.ylabel('semilogx') +plt.grid(True) +# log x and y axis +plt.subplot(313) +plt.loglog(t, 20*np.exp(-t/10.0), basex=4) +plt.grid(True) +plt.ylabel('loglog base 4 on x') - -grid(True) -gca().xaxis.grid(True, which='minor') # minor grid on too - -subplot(313) -loglog(t, 20*exp(-t/10.0), basex=4) -grid(True) -ylabel('loglog base 4 on x') -savefig('log_demo') -show() +plt.show() Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008年06月27日 13:33:33 UTC (rev 5687) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008年06月27日 15:25:50 UTC (rev 5688) @@ -2697,6 +2697,8 @@ Valid kwargs are :class:`~matplotlib.lines.Line2D` properties: %(Line2D)s + + See :meth:`axhspan` for example plot and source code """ ymin, ymax = self.get_ylim() @@ -2747,6 +2749,8 @@ Valid kwargs are :class:`~matplotlib.lines.Line2D` properties: %(Line2D)s + + See :meth:`axhspan` for example plot and source code """ xmin, xmax = self.get_xlim() @@ -2793,6 +2797,11 @@ Valid kwargs are :class:`~matplotlib.patches.Polygon` properties: %(Polygon)s + + **Example:** + + .. plot:: ../mpl_examples/pylab_examples/axhspan_demo.py + """ # convert y axis units trans = mtransforms.blended_transform_factory( @@ -2836,6 +2845,8 @@ properties: %(Polygon)s + + See :meth:`axhspan` for example plot and source code """ # convert x axis units trans = mtransforms.blended_transform_factory( @@ -3214,6 +3225,11 @@ :class:`~matplotlib.lines.Line2D` properties: %(Line2D)s + + **Example:** + + .. plot:: ../mpl_examples/pylab_examples/log_demo.py + """ if not self._hold: self.cla() @@ -3262,6 +3278,8 @@ :class:`~matplotlib.lines.Line2D` properties: %(Line2D)s + + See :meth:`loglog` for example code and figure """ if not self._hold: self.cla() d = {'basex': kwargs.pop( 'basex', 10), @@ -3303,6 +3321,8 @@ :class:`~matplotlib.lines.Line2D` properties: %(Line2D)s + + See :meth:`loglog` for example code and figure """ if not self._hold: self.cla() d = {'basey': kwargs.pop('basey', 10), @@ -3371,6 +3391,8 @@ :func:`~matplotlib.pyplot.xcorr` above, and :func:`~matplotlib.pyplot.acorr` below. + **Example:** + .. plot:: ../mpl_examples/pylab_examples/xcorr_demo.py """ return self.xcorr(x, x, **kwargs) @@ -3426,6 +3448,8 @@ :func:`~matplotlib.pyplot.xcorr` above, and :func:`~matplotlib.pyplot.acorr` below. + **Example:** + .. plot:: ../mpl_examples/pylab_examples/xcorr_demo.py """ @@ -3565,6 +3589,10 @@ *axespad*: [ None | scalar ] The border between the axes and legend edge. If *None*, use rc settings. + + **Example:** + + .. plot:: legend_demo.py """ def get_handles(): @@ -3724,10 +3752,8 @@ %(Rectangle)s - **Example:** + **Example:** A stacked bar chart. - A stacked bar chart. - .. plot:: ../mpl_examples/pylab_examples/bar_stacked.py """ if not self._hold: self.cla() @@ -4295,6 +4321,11 @@ the third element is a list of :class:`~matplotlib.collections.LineCollection` instances for the horizontal and vertical error ranges. + + **Example:** + + .. plot:: errorbar_demo.py + """ self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs) @@ -4496,6 +4527,9 @@ Returns a list of the :class:`matplotlib.lines.Line2D` instances added. + **Example:** + + .. plot:: boxplot_demo.py """ if not self._hold: self.cla() holdStatus = self._hold Modified: trunk/matplotlib/lib/matplotlib/contour.py =================================================================== --- trunk/matplotlib/lib/matplotlib/contour.py 2008年06月27日 13:33:33 UTC (rev 5687) +++ trunk/matplotlib/lib/matplotlib/contour.py 2008年06月27日 15:25:50 UTC (rev 5688) @@ -69,6 +69,7 @@ *fmt*: a format string for the label. Default is '%1.3f' + """ fontsize = kwargs.get('fontsize', None) inline = kwargs.get('inline', 1) @@ -892,4 +893,5 @@ be removed. Chunking introduces artifacts at the chunk boundaries unless *antialiased* is *False*. + .. plot:: contour_demo.py """ Modified: trunk/matplotlib/lib/matplotlib/figure.py =================================================================== --- trunk/matplotlib/lib/matplotlib/figure.py 2008年06月27日 13:33:33 UTC (rev 5687) +++ trunk/matplotlib/lib/matplotlib/figure.py 2008年06月27日 15:25:50 UTC (rev 5688) @@ -468,6 +468,9 @@ :class:`~matplotlib.axes.Axes` with size [0,1,0,1]. An :class:`matplotlib.image.FigureImage` instance is returned. + + .. plot:: ../mpl_examples/pylab_examples/figimage_demo.py + """ if not self._hold: self.clf() @@ -912,6 +915,7 @@ *axespad* the border between the axes and legend edge + .. plot:: ../mpl_examples/pylab_examples/figlegend_demo.py """ handles = flatten(handles) l = Legend(self, handles, labels, *args, **kwargs) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5687 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5687&view=rev Author: mdboom Date: 2008年06月27日 06:33:33 -0700 (2008年6月27日) Log Message: ----------- Add information about numpy copies. Add suggested replacement for offset_copy(). Modified Paths: -------------- trunk/matplotlib/API_CHANGES Modified: trunk/matplotlib/API_CHANGES =================================================================== --- trunk/matplotlib/API_CHANGES 2008年06月27日 13:31:53 UTC (rev 5686) +++ trunk/matplotlib/API_CHANGES 2008年06月27日 13:33:33 UTC (rev 5687) @@ -55,6 +55,11 @@ See transforms.py for a description of the design of the new transformation framework. + For efficiency, many of these functions return views into Numpy + arrays. This means that if you hold on to a reference to them, + their contents may change. If you want to store a snapshot of + their current values, use the Numpy array method copy(). + The view intervals are now stored only in one place -- in the Axes instance, not in the formatter instances as well. This means formatters must get their limits from their Axis, which in turn @@ -122,6 +127,8 @@ Transform.inverse_xy_tup(points) Transform.inverted().transform(points) + offset_copy(trans, x, y) trans + Affine2D().translate(x, y) + axes.py Axes.get_position() Axes.get_position() [Axes.get_position() used to return a list of points, not it This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5686 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5686&view=rev Author: mdboom Date: 2008年06月27日 06:31:53 -0700 (2008年6月27日) Log Message: ----------- Minor docstring typo (thanks, Chris Walker) Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/afm.py Modified: trunk/matplotlib/lib/matplotlib/afm.py =================================================================== --- trunk/matplotlib/lib/matplotlib/afm.py 2008年06月27日 12:51:50 UTC (rev 5685) +++ trunk/matplotlib/lib/matplotlib/afm.py 2008年06月27日 13:31:53 UTC (rev 5686) @@ -4,7 +4,7 @@ than mine) I decided not to go with them because either they were either - 1) copyighted or used a non-BSD compatible license + 1) copyrighted or used a non-BSD compatible license 2) had too many dependencies and I wanted a free standing lib This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5685 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5685&view=rev Author: mdboom Date: 2008年06月27日 05:51:50 -0700 (2008年6月27日) Log Message: ----------- Merged revisions 5678-5684 via svnmerge from https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_91_maint ........ r5684 | mdboom | 2008年06月27日 08:49:34 -0400 (2008年6月27日) | 2 lines Fix mathtext parsing bug. ........ Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/mathtext.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Name: svnmerge-integrated - /branches/v0_91_maint:1-5677 + /branches/v0_91_maint:1-5684 Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008年06月27日 12:49:34 UTC (rev 5684) +++ trunk/matplotlib/CHANGELOG 2008年06月27日 12:51:50 UTC (rev 5685) @@ -1,3 +1,5 @@ +2008年06月26日 Fix mathtext bug for expressions like $x_{\leftarrow}$ - MGD + 2008年06月26日 Fix direction of horizontal/vertical hatches - MGD 2008年06月25日 Figure.figurePatch renamed Figure.patch, Axes.axesPatch Modified: trunk/matplotlib/lib/matplotlib/mathtext.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mathtext.py 2008年06月27日 12:49:34 UTC (rev 5684) +++ trunk/matplotlib/lib/matplotlib/mathtext.py 2008年06月27日 12:51:50 UTC (rev 5685) @@ -2088,7 +2088,7 @@ start_group + ZeroOrMore( autoDelim - | simple) + ^ simple) - end_group ).setParseAction(self.group).setName("group") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5684 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5684&view=rev Author: mdboom Date: 2008年06月27日 05:49:34 -0700 (2008年6月27日) Log Message: ----------- Fix mathtext parsing bug. Modified Paths: -------------- branches/v0_91_maint/CHANGELOG branches/v0_91_maint/lib/matplotlib/mathtext.py Modified: branches/v0_91_maint/CHANGELOG =================================================================== --- branches/v0_91_maint/CHANGELOG 2008年06月26日 20:15:45 UTC (rev 5683) +++ branches/v0_91_maint/CHANGELOG 2008年06月27日 12:49:34 UTC (rev 5684) @@ -1,3 +1,5 @@ +2008年06月26日 Fix mathtext bug for expressions like $x_{\leftarrow}$ - MGD + 2008年06月26日 Fix direction of horizontal/vertical hatches - MGD =============================================================== Modified: branches/v0_91_maint/lib/matplotlib/mathtext.py =================================================================== --- branches/v0_91_maint/lib/matplotlib/mathtext.py 2008年06月26日 20:15:45 UTC (rev 5683) +++ branches/v0_91_maint/lib/matplotlib/mathtext.py 2008年06月27日 12:49:34 UTC (rev 5684) @@ -2087,7 +2087,7 @@ start_group + ZeroOrMore( autoDelim - | simple) + ^ simple) + end_group ).setParseAction(self.group).setName("group") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5683 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5683&view=rev Author: jdh2358 Date: 2008年06月26日 13:15:45 -0700 (2008年6月26日) Log Message: ----------- cleaned some more examples Modified Paths: -------------- trunk/matplotlib/examples/pylab_examples/cohere_demo.py trunk/matplotlib/examples/pylab_examples/csd_demo.py trunk/matplotlib/examples/pylab_examples/fill_demo.py trunk/matplotlib/examples/pylab_examples/hexbin_demo.py trunk/matplotlib/examples/pylab_examples/histogram_demo.py trunk/matplotlib/examples/pylab_examples/image_demo.py Added Paths: ----------- trunk/matplotlib/lib/mpl_examples Modified: trunk/matplotlib/examples/pylab_examples/cohere_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/cohere_demo.py 2008年06月26日 19:08:48 UTC (rev 5682) +++ trunk/matplotlib/examples/pylab_examples/cohere_demo.py 2008年06月26日 20:15:45 UTC (rev 5683) @@ -2,36 +2,35 @@ """ Compute the coherence of two signals """ -import numpy as n +import numpy as np +import matplotlib.pyplot as plt -from pylab import figure, show +# make a little extra space between the subplots +plt.subplots_adjust(wspace=0.5) dt = 0.01 -t = n.arange(0, 30, dt) -Nt = len(t) -nse1 = n.random.randn(Nt) # white noise 1 -nse2 = n.random.randn(Nt) # white noise 2 -r = n.exp(-t/0.05) +t = np.arange(0, 30, dt) +nse1 = np.random.randn(len(t)) # white noise 1 +nse2 = np.random.randn(len(t)) # white noise 2 +r = np.exp(-t/0.05) -cnse1 = n.convolve(nse1, r)*dt # colored noise 1 -cnse1 = cnse1[:Nt] -cnse2 = n.convolve(nse2, r)*dt # colored noise 2 -cnse2 = cnse2[:Nt] +cnse1 = np.convolve(nse1, r, mode='same')*dt # colored noise 1 +cnse2 = np.convolve(nse2, r, mode='same')*dt # colored noise 2 # two signals with a coherent part and a random part -s1 = 0.01*n.sin(2*n.pi*10*t) + cnse1 -s2 = 0.01*n.sin(2*n.pi*10*t) + cnse2 +s1 = 0.01*np.sin(2*np.pi*10*t) + cnse1 +s2 = 0.01*np.sin(2*np.pi*10*t) + cnse2 -fig = figure() -ax = fig.add_subplot(211) -ax.plot(t, s1, 'b-', t, s2, 'g-') -ax.set_xlim(0,5) -ax.set_xlabel('time') -ax.set_ylabel('s1 and s2') +plt.subplot(211) +plt.plot(t, s1, 'b-', t, s2, 'g-') +plt.xlim(0,5) +plt.xlabel('time') +plt.ylabel('s1 and s2') +plt.grid(True) -ax = fig.add_subplot(212) -cxy, f = ax.cohere(s1, s2, 256, 1./dt) +plt.subplot(212) +cxy, f = plt.cohere(s1, s2, 256, 1./dt) +plt.ylabel('coherence') +plt.show() -show() - Modified: trunk/matplotlib/examples/pylab_examples/csd_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/csd_demo.py 2008年06月26日 19:08:48 UTC (rev 5682) +++ trunk/matplotlib/examples/pylab_examples/csd_demo.py 2008年06月26日 20:15:45 UTC (rev 5683) @@ -2,32 +2,35 @@ """ Compute the cross spectral density of two signals """ -from __future__ import division -from pylab import * +import numpy as np +import matplotlib.pyplot as plt +# make a little extra space between the subplots +plt.subplots_adjust(wspace=0.5) + dt = 0.01 -t = arange(0, 30, dt) -nse1 = randn(len(t)) # white noise 1 -nse2 = randn(len(t)) # white noise 2 -r = exp(divide(-t,0.05)) +t = np.arange(0, 30, dt) +nse1 = np.random.randn(len(t)) # white noise 1 +nse2 = np.random.randn(len(t)) # white noise 2 +r = np.exp(-t/0.05) -cnse1 = convolve(nse1, r, mode=2)*dt # colored noise 1 -cnse1 = cnse1[:len(t)] -cnse2 = convolve(nse2, r, mode=2)*dt # colored noise 2 -cnse2 = cnse2[:len(t)] +cnse1 = np.convolve(nse1, r, mode='same')*dt # colored noise 1 +cnse2 = np.convolve(nse2, r, mode='same')*dt # colored noise 2 # two signals with a coherent part and a random part -s1 = 0.01*sin(2*pi*10*t) + cnse1 -s2 = 0.01*sin(2*pi*10*t) + cnse2 +s1 = 0.01*np.sin(2*np.pi*10*t) + cnse1 +s2 = 0.01*np.sin(2*np.pi*10*t) + cnse2 -subplot(211) -plot(t, s1, 'b-', t, s2, 'g-') -xlim(0,5) -xlabel('time') -ylabel('s1 and s2') +plt.subplot(211) +plt.plot(t, s1, 'b-', t, s2, 'g-') +plt.xlim(0,5) +plt.xlabel('time') +plt.ylabel('s1 and s2') +plt.grid(True) -subplot(212) -cxy, f = csd(s1, s2, 256, 1/dt) -show() +plt.subplot(212) +cxy, f = plt.csd(s1, s2, 256, 1./dt) +plt.ylabel('CSD (db)') +plt.show() Modified: trunk/matplotlib/examples/pylab_examples/fill_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/fill_demo.py 2008年06月26日 19:08:48 UTC (rev 5682) +++ trunk/matplotlib/examples/pylab_examples/fill_demo.py 2008年06月26日 20:15:45 UTC (rev 5683) @@ -1,8 +1,10 @@ #!/usr/bin/env python -from pylab import * -t = arange(0.0, 1.01, 0.01) -s = sin(2*2*pi*t) +import numpy as np +import matplotlib.pyplot as plt -fill(t, s*exp(-5*t), 'r') -grid(True) -show() +t = np.arange(0.0, 1.01, 0.01) +s = np.sin(2*2*np.pi*t) + +plt.fill(t, s*np.exp(-5*t), 'r') +plt.grid(True) +plt.show() Modified: trunk/matplotlib/examples/pylab_examples/hexbin_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/hexbin_demo.py 2008年06月26日 19:08:48 UTC (rev 5682) +++ trunk/matplotlib/examples/pylab_examples/hexbin_demo.py 2008年06月26日 20:15:45 UTC (rev 5683) @@ -1,13 +1,12 @@ -''' +""" hexbin is an axes method or pyplot function that is essentially a pcolor of a 2-D histogram with hexagonal cells. It can be much more informative than a scatter plot; in the first subplot below, try substituting 'scatter' for 'hexbin'. -''' +""" -from matplotlib.pyplot import * import numpy as np - +import matplotlib.pyplot as plt n = 100000 x = np.random.standard_normal(n) y = 2.0 + 3.0 * x + 4.0 * np.random.standard_normal(n) @@ -16,19 +15,20 @@ ymin = y.min() ymax = y.max() -subplot(121) -hexbin(x,y) -axis([xmin, xmax, ymin, ymax]) -title("Hexagon binning") -cb = colorbar() +plt.subplots_adjust(hspace=0.5) +plt.subplot(121) +plt.hexbin(x,y) +plt.axis([xmin, xmax, ymin, ymax]) +plt.title("Hexagon binning") +cb = plt.colorbar() cb.set_label('counts') -subplot(122) -hexbin(x,y,bins='log') -axis([xmin, xmax, ymin, ymax]) -title("With a log color scale") -cb = colorbar() +plt.subplot(122) +plt.hexbin(x,y,bins='log') +plt.axis([xmin, xmax, ymin, ymax]) +plt.title("With a log color scale") +cb = plt.colorbar() cb.set_label('log10(N)') -show() +plt.show() Modified: trunk/matplotlib/examples/pylab_examples/histogram_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/histogram_demo.py 2008年06月26日 19:08:48 UTC (rev 5682) +++ trunk/matplotlib/examples/pylab_examples/histogram_demo.py 2008年06月26日 20:15:45 UTC (rev 5683) @@ -1,23 +1,22 @@ #!/usr/bin/env python -import pylab as P +import numpy as np +import matplotlib.mlab as mlab +import matplotlib.pyplot as plt mu, sigma = 100, 15 -x = mu + sigma*P.randn(10000) +x = mu + sigma*np.random.randn(10000) # the histogram of the data -n, bins, patches = P.hist(x, 50, normed=1) -P.setp(patches, 'facecolor', 'g', 'alpha', 0.75) +n, bins, patches = plt.hist(x, 50, normed=1, facecolor='green', alpha=0.75) # add a 'best fit' line -y = P.normpdf( bins, mu, sigma) -l = P.plot(bins, y, 'r--') -P.setp(l, 'linewidth', 1) +y = mlab.normpdf( bins, mu, sigma) +l = plt.plot(bins, y, 'r--', linewidth=1) -P.xlabel('Smarts') -P.ylabel('Probability') -P.title(r'$\mathrm{Histogram\ of\ IQ:}\ \mu=100,\ \sigma=15$') -P.axis([40, 160, 0, 0.03]) -P.grid(True) +plt.xlabel('Smarts') +plt.ylabel('Probability') +plt.title(r'$\mathrm{Histogram\ of\ IQ:}\ \mu=100,\ \sigma=15$') +plt.axis([40, 160, 0, 0.03]) +plt.grid(True) -#P.savefig('histogram_demo',dpi=72) -P.show() +plt.show() Modified: trunk/matplotlib/examples/pylab_examples/image_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/image_demo.py 2008年06月26日 19:08:48 UTC (rev 5682) +++ trunk/matplotlib/examples/pylab_examples/image_demo.py 2008年06月26日 20:15:45 UTC (rev 5683) @@ -1,16 +1,18 @@ #!/usr/bin/env python -from pylab import * +import numpy as np +import matplotlib.cm as cm +import matplotlib.mlab as mlab +import matplotlib.pyplot as plt delta = 0.025 -x = y = arange(-3.0, 3.0, delta) -X, Y = meshgrid(x, y) -Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) -Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1) +x = y = np.arange(-3.0, 3.0, delta) +X, Y = np.meshgrid(x, y) +Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) +Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1) Z = Z2-Z1 # difference of Gaussians -im = imshow(Z, interpolation='bilinear', cmap=cm.gray, - origin='lower', extent=[-3,3,-3,3]) +im = plt.imshow(Z, interpolation='bilinear', cmap=cm.gray, + origin='lower', extent=[-3,3,-3,3]) -savefig('image_demo') -show() +plt.show() Added: trunk/matplotlib/lib/mpl_examples =================================================================== --- trunk/matplotlib/lib/mpl_examples (rev 0) +++ trunk/matplotlib/lib/mpl_examples 2008年06月26日 20:15:45 UTC (rev 5683) @@ -0,0 +1 @@ +link ../examples \ No newline at end of file Property changes on: trunk/matplotlib/lib/mpl_examples ___________________________________________________________________ Name: svn:special + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5682 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5682&view=rev Author: jdh2358 Date: 2008年06月26日 12:08:48 -0700 (2008年6月26日) Log Message: ----------- cleaned some docs for api examples Modified Paths: -------------- trunk/matplotlib/examples/pylab_examples/bar_stacked.py trunk/matplotlib/examples/pylab_examples/broken_barh.py trunk/matplotlib/examples/pylab_examples/hline_demo.py trunk/matplotlib/examples/pylab_examples/xcorr_demo.py Modified: trunk/matplotlib/examples/pylab_examples/bar_stacked.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/bar_stacked.py 2008年06月26日 18:05:17 UTC (rev 5681) +++ trunk/matplotlib/examples/pylab_examples/bar_stacked.py 2008年06月26日 19:08:48 UTC (rev 5682) @@ -1,23 +1,25 @@ #!/usr/bin/env python # a stacked bar plot with errorbars -from pylab import * +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 = arange(N) # the x locations for the groups +ind = np.arange(N) # the x locations for the groups width = 0.35 # the width of the bars: can also be len(x) sequence -p1 = bar(ind, menMeans, width, color='r', yerr=womenStd) -p2 = bar(ind, womenMeans, width, color='y', - bottom=menMeans, yerr=menStd) +p1 = plt.bar(ind, menMeans, width, color='r', yerr=womenStd) +p2 = plt.bar(ind, womenMeans, width, color='y', + bottom=menMeans, yerr=menStd) -ylabel('Scores') -title('Scores by group and gender') -xticks(ind+width/2., ('G1', 'G2', 'G3', 'G4', 'G5') ) -yticks(arange(0,81,10)) -legend( (p1[0], p2[0]), ('Men', 'Women') ) +plt.ylabel('Scores') +plt.title('Scores by group and gender') +plt.xticks(ind+width/2., ('G1', 'G2', 'G3', 'G4', 'G5') ) +plt.yticks(np.arange(0,81,10)) +plt.legend( (p1[0], p2[0]), ('Men', 'Women') ) -show() +plt.show() Modified: trunk/matplotlib/examples/pylab_examples/broken_barh.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/broken_barh.py 2008年06月26日 18:05:17 UTC (rev 5681) +++ trunk/matplotlib/examples/pylab_examples/broken_barh.py 2008年06月26日 19:08:48 UTC (rev 5682) @@ -1,10 +1,9 @@ - """ Make a "broken" horizontal bar plot, ie one with gaps """ -from matplotlib.pyplot import figure, show +import matplotlib.pyplot as plt -fig = figure() +fig = plt.figure() ax = fig.add_subplot(111) ax.broken_barh([ (110, 30), (150, 10) ] , (10, 9), facecolors='blue') ax.broken_barh([ (10, 50), (100, 20), (130, 10)] , (20, 9), @@ -22,4 +21,4 @@ horizontalalignment='right', verticalalignment='top') #fig.savefig('broken_barh', dpi=100) -show() +plt.show() Modified: trunk/matplotlib/examples/pylab_examples/hline_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/hline_demo.py 2008年06月26日 18:05:17 UTC (rev 5681) +++ trunk/matplotlib/examples/pylab_examples/hline_demo.py 2008年06月26日 19:08:48 UTC (rev 5682) @@ -1,22 +1,23 @@ #!/usr/bin/env python -from matplotlib.pyplot import * -from numpy import sin, exp, absolute, pi, arange -from numpy.random import normal +import numpy as np +import matplotlib.pyplot as plt def f(t): - s1 = sin(2*pi*t) - e1 = exp(-t) - return absolute((s1*e1))+.05 + s1 = np.sin(2*np.pi*t) + e1 = np.exp(-t) + return np.absolute((s1*e1))+.05 -t = arange(0.0, 5.0, 0.1) +t = np.arange(0.0, 5.0, 0.1) s = f(t) -nse = normal(0.0, 0.3, t.shape) * s +nse = np.random.normal(0.0, 0.3, t.shape) * s -plot(s+nse, t, 'b^') -hlines(t, [0], s) -xlabel('time (s)') -title('Comparison of model with data') -savefig('test') -show() +plt.plot(s+nse, t, 'b^') +plt.hlines(t, [0], s, lw=2) +plt.xlabel('time (s)') +plt.title('Comparison of model with data') +plt.savefig('test') +plt.xlim(xmin=0) +plt.show() + Modified: trunk/matplotlib/examples/pylab_examples/xcorr_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/xcorr_demo.py 2008年06月26日 18:05:17 UTC (rev 5681) +++ trunk/matplotlib/examples/pylab_examples/xcorr_demo.py 2008年06月26日 19:08:48 UTC (rev 5682) @@ -1,17 +1,17 @@ -from matplotlib.pylab import figure, show -import numpy +import matplotlib.pyplot as plt +import numpy as np -x,y = numpy.random.randn(2,100) -fig = figure() +x,y = np.random.randn(2,100) +fig = plt.figure() ax1 = fig.add_subplot(211) -ax1.xcorr(x, y, usevlines=True, maxlags=50, normed=True) +ax1.xcorr(x, y, usevlines=True, maxlags=50, normed=True, lw=2) ax1.grid(True) ax1.axhline(0, color='black', lw=2) ax2 = fig.add_subplot(212, sharex=ax1) -ax2.acorr(x, usevlines=True, normed=True, maxlags=50) +ax2.acorr(x, usevlines=True, normed=True, maxlags=50, lw=2) ax2.grid(True) ax2.axhline(0, color='black', lw=2) -show() +plt.show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5681 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5681&view=rev Author: mdboom Date: 2008年06月26日 11:05:17 -0700 (2008年6月26日) Log Message: ----------- Include some examples inline in the api docs. Modified Paths: -------------- trunk/matplotlib/doc/sphinxext/plot_directive.py trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/doc/sphinxext/plot_directive.py =================================================================== --- trunk/matplotlib/doc/sphinxext/plot_directive.py 2008年06月26日 17:47:04 UTC (rev 5680) +++ trunk/matplotlib/doc/sphinxext/plot_directive.py 2008年06月26日 18:05:17 UTC (rev 5681) @@ -13,7 +13,7 @@ source will be included inline, as well as a link to the source. """ -import sys, os, glob +import sys, os, glob, shutil from docutils.parsers.rst import directives try: @@ -40,29 +40,10 @@ 'class': directives.class_option, 'include-source': directives.flag } -template_no_source = """ +template = """ .. htmlonly:: - [ `<../%(srcdir)s/%(reference)s>`__, - `png <../%(srcdir)s/%(basename)s.hires.png>`__, - `pdf <../%(srcdir)s/%(basename)s.pdf>`__] - - .. image:: ../%(srcdir)s/%(basename)s.png -%(options)s - - -.. latexonly:: - .. image:: ../%(srcdir)s/%(basename)s.pdf -%(options)s - -""" - -template_source = """ -.. literalinclude:: ../pyplots/%(reference)s - -.. htmlonly:: - - [ `py <../%(srcdir)s/%(reference)s>`__, + [`py <../%(srcdir)s/%(basename)s.py>`__, `png <../%(srcdir)s/%(basename)s.hires.png>`__, `pdf <../%(srcdir)s/%(basename)s.pdf>`__] @@ -90,6 +71,9 @@ basename, ext = os.path.splitext(fname) all_exists = True + if basedir != outdir: + shutil.copyfile(fullpath, os.path.join(outdir, fname)) + for format, dpi in formats: outname = os.path.join(outdir, '%s.%s' % (basename, format)) if not os.path.exists(outname): @@ -109,10 +93,10 @@ if os.path.exists(outname): continue plt.savefig(outname, dpi=dpi) - def run(arguments, options, state_machine, lineno): reference = directives.uri(arguments[0]) - basename, ext = os.path.splitext(reference) + basedir, fname = os.path.split(reference) + basename, ext = os.path.splitext(fname) # todo - should we be using the _static dir for the outdir, I am # not sure we want to corrupt that dir with autogenerated files @@ -126,16 +110,16 @@ # the figs into the right place, so we may want to do that here instead. if options.has_key('include-source'): - template = template_source + lines = ['.. literalinclude:: ../pyplots/%(reference)s' % locals()] del options['include-source'] else: - template = template_no_source + lines = [] + options = [' :%s: %s' % (key, val) for key, val in options.items()] options = "\n".join(options) - lines = template % locals() - lines = lines.split('\n') + lines.extend((template % locals()).split('\n')) state_machine.insert_input( lines, state_machine.input_lines.source(0)) Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008年06月26日 17:47:04 UTC (rev 5680) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008年06月26日 18:05:17 UTC (rev 5681) @@ -2879,6 +2879,9 @@ *linestyle*: [ 'solid' | 'dashed' | 'dashdot' | 'dotted' ] + **Example:** + + .. plot:: ../mpl_examples/pylab_examples/hline_demo.py """ if kwargs.get('fmt') is not None: raise DeprecationWarning( @@ -3362,6 +3365,13 @@ See the respective :meth:`~matplotlib.axes.Axes.plot` or :meth:`~matplotlib.axes.Axes.vlines` functions for documentation on valid kwargs. + + **Example:** + + :func:`~matplotlib.pyplot.xcorr` above, and + :func:`~matplotlib.pyplot.acorr` below. + + .. plot:: ../mpl_examples/pylab_examples/xcorr_demo.py """ return self.xcorr(x, x, **kwargs) acorr.__doc__ = cbook.dedent(acorr.__doc__) % martist.kwdocd @@ -3410,6 +3420,13 @@ *maxlags* is a positive integer detailing the number of lags to show. The default value of *None* will return all ``(2*len(x)-1)`` lags. + + **Example:** + + :func:`~matplotlib.pyplot.xcorr` above, and + :func:`~matplotlib.pyplot.acorr` below. + + .. plot:: ../mpl_examples/pylab_examples/xcorr_demo.py """ Nx = len(x) @@ -3706,6 +3723,12 @@ Other optional kwargs: %(Rectangle)s + + **Example:** + + A stacked bar chart. + + .. plot:: ../mpl_examples/pylab_examples/bar_stacked.py """ if not self._hold: self.cla() @@ -3998,6 +4021,10 @@ or a sequence of arguments for the various bars, ie:: facecolors = ('black', 'red', 'green') + + **Example:** + + .. plot:: ../mpl_examples/pylab_examples/broken_barh.py """ col = mcoll.BrokenBarHCollection(xranges, yrange, **kwargs) self.add_collection(col, autolim=True) @@ -5013,6 +5040,10 @@ :meth:`~matplotlib.collection.PolyCollection.get_array` on this :class:`~matplotlib.collections.PolyCollection` to get the counts in each hexagon. + + **Example:** + + .. plot:: ../mpl_examples/pylab_examples/hexbin_demo.py """ if not self._hold: self.cla() @@ -5166,6 +5197,10 @@ Optional kwargs control the arrow properties: %(FancyArrow)s + + **Example:** + + .. plot:: ../mpl_examples/pylab_examples/arrow_demo.py """ a = mpatches.FancyArrow(x, y, dx, dy, **kwargs) self.add_artist(a) @@ -5225,6 +5260,10 @@ kwargs control the Polygon properties: %(Polygon)s + + **Example:** + + .. plot:: ../mpl_examples/pylab_examples/fill_demo.py """ if not self._hold: self.cla() @@ -5334,6 +5373,10 @@ Additional kwargs are :class:`~matplotlib.artist.Artist` properties: %(Artist)s + + **Example:** + + .. plot:: ../mpl_examples/pylab_examples/image_demo.py """ if not self._hold: self.cla() @@ -6081,42 +6124,6 @@ %(Rectangle)s - Here is an example which generates a histogram of normally - distributed random numbers and plot the analytic PDF over it:: - - import numpy as np - import matplotlib.pyplot as plt - import matplotlib.mlab as mlab - - mu, sigma = 100, 15 - x = mu + sigma * np.random.randn(10000) - - fig = plt.figure() - ax = fig.add_subplot(111) - - # the histogram of the data - n, bins, patches = ax.hist(x, 50, normed=1, facecolor='green', alpha=0.75) - - # hist uses np.histogram under the hood to create 'n' and 'bins'. - # np.histogram returns the bin edges, so there will be 50 probability - # density values in n, 51 bin edges in bins and 50 patches. To get - # everything lined up, we'll compute the bin centers - bincenters = 0.5*(bins[1:]+bins[:-1]) - - # add a 'best fit' line for the normal PDF - y = mlab.normpdf( bincenters, mu, sigma) - l = ax.plot(bincenters, y, 'r--', linewidth=1) - - ax.set_xlabel('Smarts') - ax.set_ylabel('Probability') - ax.set_title(r'$\mathrm{Histogram\ of\ IQ:}\ \mu=100,\ \sigma=15$') - ax.set_xlim(40, 160) - ax.set_ylim(0, 0.03) - ax.grid(True) - - #fig.savefig('histogram_demo',dpi=72) - plt.show() - You can use labels for your histogram, and only the first :class:`~matplotlib.patches.Rectangle` gets the label (the others get the magic string '_nolegend_'. This will make the @@ -6126,6 +6133,9 @@ ax.hist(12+3*np.random.randn(1000), label='women', alpha=0.5) ax.legend() + **Example:** + + .. plot:: ../mpl_examples/pylab_examples/histogram_demo.py """ if not self._hold: self.cla() @@ -6413,6 +6423,10 @@ kwargs control the Line2D properties: %(Line2D)s + + **Example:** + + .. plot:: ../mpl_examples/pylab_examples/csd_demo.py """ if not self._hold: self.cla() pxy, freqs = mlab.csd(x, y, NFFT, Fs, detrend, window, noverlap) @@ -6466,6 +6480,10 @@ properties of the coherence plot: %(Line2D)s + + **Example:** + + .. plot:: ../mpl_examples/pylab_examples/cohere_demo.py """ if not self._hold: self.cla() cxy, freqs = mlab.cohere(x, y, NFFT, Fs, detrend, window, noverlap) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5680 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5680&view=rev Author: mdboom Date: 2008年06月26日 10:47:04 -0700 (2008年6月26日) Log Message: ----------- Fix documentation build on Debian. Modified Paths: -------------- trunk/matplotlib/doc/pyplots/tex_unicode_demo.py Modified: trunk/matplotlib/doc/pyplots/tex_unicode_demo.py =================================================================== --- trunk/matplotlib/doc/pyplots/tex_unicode_demo.py 2008年06月26日 14:05:34 UTC (rev 5679) +++ trunk/matplotlib/doc/pyplots/tex_unicode_demo.py 2008年06月26日 17:47:04 UTC (rev 5680) @@ -13,7 +13,7 @@ plot(t, s) xlabel(r'\textbf{time (s)}') -ylabel(unicode(r'\textit{Velocity (\xB0/sec)}','latin-1'),fontsize=16) +ylabel(unicode('\\textit{Velocity (\xB0/sec)}','latin-1'),fontsize=16) title(r"\TeX\ is Number $\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!", fontsize=16, color='r') grid(True) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5679 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5679&view=rev Author: mdboom Date: 2008年06月26日 07:05:34 -0700 (2008年6月26日) Log Message: ----------- Tagging 0.98.2 release. Added Paths: ----------- tags/v0_98_2/ Copied: tags/v0_98_2 (from rev 5667, trunk/matplotlib) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5678 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5678&view=rev Author: mdboom Date: 2008年06月26日 05:39:30 -0700 (2008年6月26日) Log Message: ----------- Merged revisions 5676-5677 via svnmerge from https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_91_maint ........ r5677 | mdboom | 2008年06月26日 08:36:15 -0400 (2008年6月26日) | 1 line Oops in last commit ........ Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Name: svnmerge-integrated - /branches/v0_91_maint:1-5675 + /branches/v0_91_maint:1-5677 Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008年06月26日 12:36:15 UTC (rev 5677) +++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008年06月26日 12:39:30 UTC (rev 5678) @@ -254,7 +254,7 @@ hatchr cvi hatchgap idiv hatchgap mul {hatcht m 0 hatchb hatcht sub r } for - strokeCHAN + stroke grestore """ % (angle, 12/density) self._pswriter.write("gsave\n") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5677 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5677&view=rev Author: mdboom Date: 2008年06月26日 05:36:15 -0700 (2008年6月26日) Log Message: ----------- Oops in last commit Modified Paths: -------------- branches/v0_91_maint/lib/matplotlib/backends/backend_ps.py Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_ps.py =================================================================== --- branches/v0_91_maint/lib/matplotlib/backends/backend_ps.py 2008年06月26日 12:32:32 UTC (rev 5676) +++ branches/v0_91_maint/lib/matplotlib/backends/backend_ps.py 2008年06月26日 12:36:15 UTC (rev 5677) @@ -254,7 +254,7 @@ hatchr cvi hatchgap idiv hatchgap mul {hatcht moveto 0 hatchb hatcht sub rlineto} for - strokeCHAN + stroke grestore """ % (angle, 12/density) self._pswriter.write("gsave\n") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.