SourceForge logo
SourceForge logo
Menu

matplotlib-devel — matplotlib developers

You can subscribe to this list here.

2003 Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
(1)
Nov
(33)
Dec
(20)
2004 Jan
(7)
Feb
(44)
Mar
(51)
Apr
(43)
May
(43)
Jun
(36)
Jul
(61)
Aug
(44)
Sep
(25)
Oct
(82)
Nov
(97)
Dec
(47)
2005 Jan
(77)
Feb
(143)
Mar
(42)
Apr
(31)
May
(93)
Jun
(93)
Jul
(35)
Aug
(78)
Sep
(56)
Oct
(44)
Nov
(72)
Dec
(75)
2006 Jan
(116)
Feb
(99)
Mar
(181)
Apr
(171)
May
(112)
Jun
(86)
Jul
(91)
Aug
(111)
Sep
(77)
Oct
(72)
Nov
(57)
Dec
(51)
2007 Jan
(64)
Feb
(116)
Mar
(70)
Apr
(74)
May
(53)
Jun
(40)
Jul
(519)
Aug
(151)
Sep
(132)
Oct
(74)
Nov
(282)
Dec
(190)
2008 Jan
(141)
Feb
(67)
Mar
(69)
Apr
(96)
May
(227)
Jun
(404)
Jul
(399)
Aug
(96)
Sep
(120)
Oct
(205)
Nov
(126)
Dec
(261)
2009 Jan
(136)
Feb
(136)
Mar
(119)
Apr
(124)
May
(155)
Jun
(98)
Jul
(136)
Aug
(292)
Sep
(174)
Oct
(126)
Nov
(126)
Dec
(79)
2010 Jan
(109)
Feb
(83)
Mar
(139)
Apr
(91)
May
(79)
Jun
(164)
Jul
(184)
Aug
(146)
Sep
(163)
Oct
(128)
Nov
(70)
Dec
(73)
2011 Jan
(235)
Feb
(165)
Mar
(147)
Apr
(86)
May
(74)
Jun
(118)
Jul
(65)
Aug
(75)
Sep
(162)
Oct
(94)
Nov
(48)
Dec
(44)
2012 Jan
(49)
Feb
(40)
Mar
(88)
Apr
(35)
May
(52)
Jun
(69)
Jul
(90)
Aug
(123)
Sep
(112)
Oct
(120)
Nov
(105)
Dec
(116)
2013 Jan
(76)
Feb
(26)
Mar
(78)
Apr
(43)
May
(61)
Jun
(53)
Jul
(147)
Aug
(85)
Sep
(83)
Oct
(122)
Nov
(18)
Dec
(27)
2014 Jan
(58)
Feb
(25)
Mar
(49)
Apr
(17)
May
(29)
Jun
(39)
Jul
(53)
Aug
(52)
Sep
(35)
Oct
(47)
Nov
(110)
Dec
(27)
2015 Jan
(50)
Feb
(93)
Mar
(96)
Apr
(30)
May
(55)
Jun
(83)
Jul
(44)
Aug
(8)
Sep
(5)
Oct
Nov
(1)
Dec
(1)
2016 Jan
Feb
Mar
(1)
Apr
May
Jun
(2)
Jul
Aug
(3)
Sep
(1)
Oct
(3)
Nov
Dec
2017 Jan
Feb
(5)
Mar
Apr
May
Jun
Jul
(3)
Aug
Sep
(7)
Oct
Nov
Dec
2018 Jan
Feb
Mar
Apr
May
Jun
Jul
(2)
Aug
Sep
Oct
Nov
Dec
S M T W T F S


1
(3)
2
(2)
3
(4)
4
(4)
5
6
7
8
(2)
9
(4)
10
(3)
11
12
(2)
13
14
15
(1)
16
(4)
17
18
(4)
19
(5)
20
(8)
21
(4)
22
(3)
23
(1)
24
(3)
25
26
(1)
27
(3)
28
(1)
29
(1)
30
(9)



Showing 3 results of 3

From: James C. <ca...@gm...> - 2005年11月24日 15:23:22
Hi,
The logic for displaying a figure on the interactive backends (eg qt)
seems a little strange to me. I imagine that normally the screen is
used as a preview for a figure that is going to be output on paper, or
to png or some permanent store. Therefore, the interactive output
should resemble the permanent output as much as possible.
Now, when using the QtAgg backend (sorry no time to play with other
backends) setting the figure height or width has no effect on the size
of the figure displayed with show(). It always comes out at 600x400.
Further, given that the window can be resized or embedded, ideally
what is displayed should be as good a representation of the figure as
possible. It is not, however. To see this try resizing the window -
fonts sizes, linewidths, etc. stay the same size.
I can make the rendering more realistic using the dpi setting. This
can be achieved using this implementation of resizeEvent (from
backend_qt_agg.py / FigureCanvasQtAgg). The original code is
commented.
 def resizeEvent( self, e ):
 FigureCanvasQT.resizeEvent( self, e )
 w =3D e.size().width()
 h =3D e.size().height()
 if DEBUG: print "FigureCanvasQtAgg.resizeEvent(", w, ",", h, ")"
 #dpival =3D self.figure.dpi.get()
 #winch =3D w/dpival
 #hinch =3D h/dpival
 #self.figure.set_figsize_inches( winch, hinch )
 if w/self.figure.get_figwidth() < h/self.figure.get_figheight():
 self.figure.set_dpi( w/self.figure.get_figwidth() )
 else:
 self.figure.set_dpi( h/self.figure.get_figheight() )
 self.draw()
The original implementation doesn't really do anything to how the
figure is displayed. The new one makes the plot appear how it should
no matter what the window's size.
This is not ideal, however, as if the figure is saved now the dpi will
be wrong. So there are two questions really: is this a better way
for the interactive windows to display? If so, where should this
logic go?
thanks,
James
From: Alexander M. <ale...@co...> - 2005年11月24日 03:34:09
from __future__ import division, generators
import math, sys
from numerix import absolute, arange, array, asarray, ones, divide,\
 transpose, log, log10, Float, Float32, ravel, zeros,\
 Int16, Int32, Int, Float64, ceil, indices, \
 shape, which, where, sqrt, asum, compress, maximum, minimum
import numerix.ma as ma
import matplotlib.mlab
from artist import Artist, setp
from axis import XAxis, YAxis
from cbook import iterable, is_string_like, flatten, enumerate, \
 allequal, dict_delall, popd, popall, silent_list
from collections import RegularPolyCollection, PolyCollection, =
LineCollection
from colors import colorConverter, normalize, Colormap, =
LinearSegmentedColormap, looks_like_color
import cm
#from cm import ColormapJet, Grayscale, ScalarMappable
from cm import ScalarMappable
from contour import ContourSet
import _image
from ticker import AutoLocator, LogLocator, NullLocator
from ticker import ScalarFormatter, LogFormatter, LogFormatterExponent, =
LogFormatterMathtext, NullFormatter
from image import AxesImage
from legend import Legend
from lines import Line2D, lineStyles, lineMarkers
from matplotlib.mlab import meshgrid, detrend_none, detrend_linear, \
 window_none, window_hanning, linspace, prctile
from matplotlib.numerix.mlab import flipud, amin, amax
from matplotlib import rcParams
from patches import Patch, Rectangle, Circle, Polygon, Arrow, Wedge, =
Shadow, bbox_artist
from table import Table
from text import Text, TextWithDash, _process_text_args
from transforms import Bbox, Point, Value, Affine, =
NonseparableTransformation
from transforms import FuncXY, Func, LOG10, IDENTITY, POLAR
from transforms import get_bbox_transform, unit_bbox, one, origin, zero
from transforms import blend_xy_sep_transform, Interval
from font_manager import FontProperties
import matplotlib
if matplotlib._havedate:
 from dates import date_ticker_factory
def _process_plot_format(fmt):
 """
 Process a matlab(TM) style color/line style format string. Return a
 linestyle, color tuple as a result of the processing. Default
 values are ('-', 'b'). Example format strings include
 'ko' : black circles
 '.b' : blue dots
 'r--' : red dashed lines
 See Line2D.lineStyles and GraphicsContext.colors for all possible
 styles and color format string.
 """
 colors =3D {
 'b' : 1,
 'g' : 1,
 'r' : 1,
 'c' : 1,
 'm' : 1,
 'y' : 1,
 'k' : 1,
 'w' : 1,
 }
 linestyle =3D 'None'
 marker =3D 'None'
 color =3D rcParams['lines.color']
 # handle the multi char special cases and strip them from the
 # string
 if fmt.find('--')>=3D0:
 linestyle =3D '--'
 fmt =3D fmt.replace('--', '')
 if fmt.find('-.')>=3D0:
 linestyle =3D '-.'
 fmt =3D fmt.replace('-.', '')
 chars =3D [c for c in fmt]
 for c in chars:
 if lineStyles.has_key(c):
 if linestyle !=3D 'None':
 raise ValueError, 'Illegal format string "%s"; two =
linestyle symbols' % fmt
 linestyle =3D c
 elif lineMarkers.has_key(c):
 if marker !=3D 'None':
 raise ValueError, 'Illegal format string "%s"; two =
marker symbols' % fmt
 marker =3D c
 elif colors.has_key(c):
 color =3D c
 else:
 err =3D 'Unrecognized character %c in format string' % c
 raise ValueError, err
 if linestyle =3D=3D 'None' and marker =3D=3D 'None':
 linestyle =3D rcParams['lines.linestyle']
 return linestyle, marker, color
class _process_plot_var_args:
 """
 Process variable length arguments to the plot command, so that
 plot commands like the following are supported
 plot(t, s)
 plot(t1, s1, t2, s2)
 plot(t1, s1, 'ko', t2, s2)
 plot(t1, s1, 'ko', t2, s2, 'r--', t3, e3)
 an arbitrary number of x, y, fmt are allowed
 """
 def __init__(self, command=3D'plot'):
 self.command =3D command
 self._clear_color_cycle()
 def _clear_color_cycle(self):
 self.colors =3D ['b','g','r','c','m','y','k']
 # if the default line color is a color format string, move it up
 # in the que
 try: ind =3D self.colors.index(rcParams['lines.color'])
 except ValueError:
 self.firstColor =3D rcParams['lines.color']
 else:
 self.colors[0], self.colors[ind] =3D self.colors[ind], =
self.colors[0]
 self.firstColor =3D self.colors[0]
 self.Ncolors =3D len(self.colors)
 self.count =3D 0
 def __call__(self, *args, **kwargs):
 ret =3D self._grab_next_args(*args, **kwargs)
 return ret
 def set_lineprops(self, line, **kwargs):
 assert self.command =3D=3D 'plot', 'set_lineprops only works =
with "plot"'
 for key, val in kwargs.items():
 funcName =3D "set_%s"%key
 if not hasattr(line,funcName):
 raise TypeError, 'There is no line property "%s"'%key
 func =3D getattr(line,funcName)
 func(val)
 def set_patchprops(self, fill_poly, **kwargs):
 assert self.command =3D=3D 'fill', 'set_patchprops only works =
with "fill"'
 for key, val in kwargs.items():
 funcName =3D "set_%s"%key
 if not hasattr(fill_poly,funcName):
 raise TypeError, 'There is no patch property "%s"'%key
 func =3D getattr(fill_poly,funcName)
 func(val)
 def is_filled(self, marker):
 filled =3D ('o', '^', 'v', '<', '>', 's',
 'd', 'D', 'h', 'H',
 'p')
 return marker in filled
 def _plot_1_arg(self, y, **kwargs):
 assert self.command =3D=3D 'plot', 'fill needs at least 2 =
arguments'
 if self.count=3D=3D0:
 color =3D self.firstColor
 else:
 color =3D self.colors[int(self.count % self.Ncolors)]
 assert(iterable(y))
 try: N=3Dmax(y.shape)
 except AttributeError: N =3D len(y)
 ret =3D Line2D(arange(N), y,
 color =3D color,
 markerfacecolor=3Dcolor,
 )
 self.set_lineprops(ret, **kwargs)
 self.count +=3D 1
 return ret
 def _plot_2_args(self, tup2, **kwargs):
 if is_string_like(tup2[1]):
 assert self.command =3D=3D 'plot', 'fill needs at least 2 =
non-string arguments'
 y, fmt =3D tup2
 assert(iterable(y))
 linestyle, marker, color =3D _process_plot_format(fmt)
 if self.is_filled(marker): mec =3D None # use default
 else: mec =3D color # use current color
 try: N=3Dmax(y.shape)
 except AttributeError: N =3D len(y)
 ret =3D Line2D(xdata=3Darange(N), ydata=3Dy,
 color=3Dcolor, linestyle=3Dlinestyle, =
marker=3Dmarker,
 markerfacecolor=3Dcolor,
 markeredgecolor=3Dmec,
 )
 self.set_lineprops(ret, **kwargs)
 return ret
 else:
 x,y =3D tup2
 #print self.count, self.Ncolors, self.count % self.Ncolors
 assert(iterable(x))
 assert(iterable(y))
 if self.command =3D=3D 'plot':
 c =3D self.colors[self.count % self.Ncolors]
 ret =3D Line2D(x, y,
 color =3D c,
 markerfacecolor =3D c,
 )
 self.set_lineprops(ret, **kwargs)
 self.count +=3D 1
 elif self.command =3D=3D 'fill':
 ret =3D Polygon( zip(x,y), fill=3DTrue, )
 self.set_patchprops(ret, **kwargs)
 return ret
 def _plot_3_args(self, tup3, **kwargs):
 if self.command =3D=3D 'plot':
 x, y, fmt =3D tup3
 assert(iterable(x))
 assert(iterable(y))
 linestyle, marker, color =3D _process_plot_format(fmt)
 if self.is_filled(marker): mec =3D None # use default
 else: mec =3D color # use current color
 ret =3D Line2D(x, y, color=3Dcolor,
 linestyle=3Dlinestyle, marker=3Dmarker,
 markerfacecolor=3Dcolor,
 markeredgecolor=3Dmec,
 )
 self.set_lineprops(ret, **kwargs)
 if self.command =3D=3D 'fill':
 x, y, facecolor =3D tup3
 ret =3D Polygon(zip(x,y),
 facecolor =3D facecolor,
 fill=3DTrue,
 )
 self.set_patchprops(ret, **kwargs)
 return ret
 def _grab_next_args(self, *args, **kwargs):
 remaining =3D args
 while 1:
 if len(remaining)=3D=3D0: return
 if len(remaining)=3D=3D1:
 yield self._plot_1_arg(remaining[0], **kwargs)
 remaining =3D []
 continue
 if len(remaining)=3D=3D2:
 yield self._plot_2_args(remaining, **kwargs)
 remaining =3D []
 continue
 if len(remaining)=3D=3D3:
 if not is_string_like(remaining[2]):
 raise ValueError, 'third arg must be a format =
string'
 yield self._plot_3_args(remaining, **kwargs)
 remaining=3D[]
 continue
 if is_string_like(remaining[2]):
 yield self._plot_3_args(remaining[:3], **kwargs)
 remaining=3Dremaining[3:]
 else:
 yield self._plot_2_args(remaining[:2], **kwargs)
 remaining=3Dremaining[2:]
 #yield self._plot_2_args(remaining[:2])
 #remaining=3Dargs[2:]
BinOpType=3Dtype(zero())
def makeValue(v):
 if type(v) =3D=3D BinOpType:
 return v
 else:
 return Value(v)
class Axes(Artist):
 """
 Emulate matlab's (TM) axes command, creating axes with
 Axes(position=3D[left, bottom, width, height])
 where all the arguments are fractions in [0,1] which specify the
 fraction of the total figure window.
 axisbg is the color of the axis background
 """
 scaled =3D {IDENTITY : 'linear',
 LOG10 : 'log',
 }
 def __init__(self, fig, rect,
 axisbg =3D None, # defaults to rc axes.facecolor
 frameon =3D True,
 sharex=3DNone, # use Axes instance's xaxis info
 sharey=3DNone, # use Axes instance's yaxis info
 label=3D'',
 **kwargs
 ):
 Artist.__init__(self)
 self._position =3D map(makeValue, rect)
 # must be set before set_figure
 self._sharex =3D sharex
 self._sharey =3D sharey
 self.set_label(label)
 self.set_figure(fig)
 # this call may differ for non-sep axes, eg polar
 self._init_axis()
 if axisbg is None: axisbg =3D rcParams['axes.facecolor']
 self._axisbg =3D axisbg
 self._frameon =3D frameon
 self._axisbelow =3D False # todo make me an rcparam
 self._hold =3D rcParams['axes.hold']
 self._connected =3D {} # a dict from events to (id, func)
 self.cla()
 # funcs used to format x and y - fall back on major formatters
 self.fmt_xdata =3D None
 self.fmt_ydata =3D None
 self.set_cursor_props((1,'k')) # set the cursor properties for =
axes
 self._cachedRenderer =3D None
 self.set_navigate(True)
 # aspect ration atribute, and original position
 self._aspect =3D 'normal'
 self._originalPosition =3D self.get_position()
 if len(kwargs): setp(self, **kwargs)
 def _init_axis(self):
 "move this out of __init__ because non-separable axes don't use =
it"
 self.xaxis =3D XAxis(self)
 self.yaxis =3D YAxis(self)
 def set_cursor_props(self, *args):
 """
 Set the cursor property as
 ax.set_cursor_props(linewidth, color) OR
 ax.set_cursor_props((linewidth, color))
 ACCEPTS: a (float, color) tuple
 """
 if len(args)=3D=3D1:
 lw, c =3D args[0]
 elif len(args)=3D=3D2:
 lw, c =3D args
 else:
 raise ValueError('args must be a (linewidth, color) tuple')
 c =3DcolorConverter.to_rgba(c)
 self._cursorProps =3D lw, c
 def get_cursor_props(self):
 """return the cursor props as a linewidth, color tuple where
 linewidth is a float and color is an RGBA tuple"""
 return self._cursorProps
 def set_figure(self, fig):
 """
 Set the Axes figure
 ACCEPTS: a Figure instance
 """
 Artist.set_figure(self, fig)
 l, b, w, h =3D self._position
 xmin =3D fig.bbox.ll().x()
 xmax =3D fig.bbox.ur().x()
 ymin =3D fig.bbox.ll().y()
 ymax =3D fig.bbox.ur().y()
 figw =3D xmax-xmin
 figh =3D ymax-ymin
 self.left =3D l*figw
 self.bottom =3D b*figh
 self.right =3D (l+w)*figw
 self.top =3D (b+h)*figh
 self.bbox =3D Bbox( Point(self.left, self.bottom),
 Point(self.right, self.top ),
 )
 #these will be updated later as data is added
 self._set_lim_and_transforms()
 def _set_lim_and_transforms(self):
 """
 set the dataLim and viewLim BBox attributes and the
 transData and transAxes Transformation attributes
 """
 if self._sharex is not None:
 left=3Dself._sharex.viewLim.ll().x()
 right=3Dself._sharex.viewLim.ur().x()
 else:
 left=3Dzero()
 right=3Done()
 if self._sharey is not None:
 bottom=3Dself._sharey.viewLim.ll().y()
 top=3Dself._sharey.viewLim.ur().y()
 else:
 bottom=3Dzero()
 top=3Done()
 self.viewLim =3D Bbox(Point(left, bottom), Point(right, top))
 self.dataLim =3D unit_bbox()
 self.transData =3D get_bbox_transform(self.viewLim, self.bbox)
 self.transAxes =3D get_bbox_transform(unit_bbox(), self.bbox)
 if self._sharex:
 self.transData.set_funcx(self._sharex.transData.get_funcx())
 if self._sharey:
 self.transData.set_funcy(self._sharey.transData.get_funcy())
 def axhline(self, y=3D0, xmin=3D0, xmax=3D1, **kwargs):
 """
 AXHLINE(y=3D0, xmin=3D0, xmax=3D1, **kwargs)
 Axis Horizontal Line
 Draw a horizontal line at y from xmin to xmax. With the default
 values of xmin=3D0 and xmax=3D1, this line will always span the =
horizontal
 extent of the axes, regardless of the xlim settings, even if you
 change them, eg with the xlim command. That is, the horizontal =
extent
 is in axes coords: 0=3Dleft, 0.5=3Dmiddle, 1.0=3Dright but the y =
location is
 in data coordinates.
 Return value is the Line2D instance. kwargs are the same as =
kwargs to
 plot, and can be used to control the line properties. Eg
 # draw a thick red hline at y=3D0 that spans the xrange
 axhline(linewidth=3D4, color=3D'r')
 # draw a default hline at y=3D1 that spans the xrange
 axhline(y=3D1)
 # draw a default hline at y=3D.5 that spans the the middle =
half of
 # the xrange
 axhline(y=3D.5, xmin=3D0.25, xmax=3D0.75)
 """
 trans =3D blend_xy_sep_transform( self.transAxes, =
self.transData)
 l, =3D self.plot([xmin,xmax], [y,y], transform=3Dtrans, =
**kwargs)
 return l
 def axvline(self, x=3D0, ymin=3D0, ymax=3D1, **kwargs):
 """
 AXVLINE(x=3D0, ymin=3D0, ymax=3D1, **kwargs)
 Axis Vertical Line
 Draw a vertical line at x from ymin to ymax. With the default =
values
 of ymin=3D0 and ymax=3D1, this line will always span the =
vertical extent
 of the axes, regardless of the xlim settings, even if you change =
them,
 eg with the xlim command. That is, the vertical extent is in =
axes
 coords: 0=3Dbottom, 0.5=3Dmiddle, 1.0=3Dtop but the x location =
is in data
 coordinates.
 Return value is the Line2D instance. kwargs are the same as
 kwargs to plot, and can be used to control the line properties. =
Eg
 # draw a thick red vline at x=3D0 that spans the yrange
 l =3D axvline(linewidth=3D4, color=3D'r')
 # draw a default vline at x=3D1 that spans the yrange
 l =3D axvline(x=3D1)
 # draw a default vline at x=3D.5 that spans the the middle =
half of
 # the yrange
 axvline(x=3D.5, ymin=3D0.25, ymax=3D0.75)
 """
 trans =3D blend_xy_sep_transform( self.transData, self.transAxes =
)
 l, =3D self.plot([x,x], [ymin,ymax] , transform=3Dtrans, =
**kwargs)
 return l
 def axhspan(self, ymin, ymax, xmin=3D0, xmax=3D1, **kwargs):
 """
 AXHSPAN(ymin, ymax, xmin=3D0, xmax=3D1, **kwargs)
 Axis Horizontal Span. ycoords are in data units and x
 coords are in axes (relative 0-1) units
 Draw a horizontal span (regtangle) from ymin to ymax. With the
 default values of xmin=3D0 and xmax=3D1, this always span the =
xrange,
 regardless of the xlim settings, even if you change them, eg =
with the
 xlim command. That is, the horizontal extent is in axes coords:
 0=3Dleft, 0.5=3Dmiddle, 1.0=3Dright but the y location is in =
data
 coordinates.
 kwargs are the kwargs to Patch, eg
 antialiased, aa
 linewidth, lw
 edgecolor, ec
 facecolor, fc
 the terms on the right are aliases
 Return value is the patches.Polygon instance.
 #draws a gray rectangle from y=3D0.25-0.75 that spans the =
horizontal
 #extent of the axes
 axhspan(0.25, 0.75, facecolor=3D0.5, alpha=3D0.5)
 """
 trans =3D blend_xy_sep_transform( self.transAxes, self.transData =
 )
 verts =3D (xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, ymin)
 p =3D Polygon(verts, **kwargs)
 p.set_transform(trans)
 self.add_patch(p)
 return p
 def axvspan(self, xmin, xmax, ymin=3D0, ymax=3D1, **kwargs):
 """
 AXVSPAN(xmin, xmax, ymin=3D0, ymax=3D1, **kwargs)
 axvspan : Axis Vertical Span. xcoords are in data units and y =
coords
 are in axes (relative 0-1) units
 Draw a vertical span (regtangle) from xmin to xmax. With the =
default
 values of ymin=3D0 and ymax=3D1, this always span the yrange, =
regardless
 of the ylim settings, even if you change them, eg with the ylim
 command. That is, the vertical extent is in axes coords: =
0=3Dbottom,
 0.5=3Dmiddle, 1.0=3Dtop but the y location is in data =
coordinates.
 kwargs are the kwargs to Patch, eg
 antialiased, aa
 linewidth, lw
 edgecolor, ec
 facecolor, fc
 the terms on the right are aliases
 return value is the patches.Polygon instance.
 # draw a vertical green translucent rectangle from x=3D1.25 =
to 1.55 that
 # spans the yrange of the axes
 axvspan(1.25, 1.55, facecolor=3D'g', alpha=3D0.5)
 """
 trans =3D blend_xy_sep_transform( self.transData, self.transAxes =
 )
 verts =3D [(xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, =
ymin)]
 p =3D Polygon(verts, **kwargs)
 p.set_transform(trans)
 self.add_patch(p)
 return p
 def format_xdata(self, x):
 """
 Return x string formatted. This function will use the attribute
 self.fmt_xdata if it is callable, else will fall back on the =
xaxis
 major formatter
 """
 try: return self.fmt_xdata(x)
 except TypeError:
 func =3D self.xaxis.get_major_formatter().format_data
 val =3D func(x)
 return val
 def format_ydata(self, y):
 """
 Return y string formatted. This function will use the attribute
 self.fmt_ydata if it is callable, else will fall back on the =
yaxis
 major formatter
 """
 try: return self.fmt_ydata(y)
 except TypeError:
 func =3D self.yaxis.get_major_formatter().format_data
 val =3D func(y)
 return val
 def format_coord(self, x, y):
 'return a format string formatting the x, y coord'
 =20
 xs =3D self.format_xdata(x)
 ys =3D self.format_ydata(y)
 return 'x=3D%s, y=3D%s'%(xs,ys)
 def has_data(self):
 'return true if any artists have been added to axes'
 return (
 len(self.collections) +
 len(self.images) +
 len(self.lines) +
 len(self.patches))>0
 def _set_artist_props(self, a):
 'set the boilerplate props for artists added to axes'
 a.set_figure(self.figure)
 if not a.is_transform_set():
 a.set_transform(self.transData)
 a.axes =3D self
 def cla(self):
 'Clear the current axes'
 self.xaxis.cla()
 self.yaxis.cla()
 if self._sharex is not None:
 self.xaxis.major =3D self._sharex.xaxis.major
 self.xaxis.minor =3D self._sharex.xaxis.minor
 if self._sharey is not None:
 self.yaxis.major =3D self._sharey.yaxis.major
 self.yaxis.minor =3D self._sharey.yaxis.minor
 self._get_lines =3D _process_plot_var_args()
 self._get_patches_for_fill =3D _process_plot_var_args('fill')
 self._gridOn =3D rcParams['axes.grid']
 self.lines =3D []
 self.patches =3D []
 self.texts =3D [] # text in axis coords
 self.tables =3D []
 self.artists =3D []
 self.images =3D []
 self.legend_ =3D None
 self.collections =3D [] # collection.Collection instances
 self._autoscaleon =3D True
 self.grid(self._gridOn)
 self.title =3D Text(
 x=3D0.5, y=3D1.02, text=3D'',
 =
fontproperties=3DFontProperties(size=3DrcParams['axes.titlesize']),
 verticalalignment=3D'bottom',
 horizontalalignment=3D'center',
 )
 self.title.set_transform(self.transAxes)
 self.title.set_clip_box(None) =20
 self._set_artist_props(self.title)
 self.axesPatch =3D Rectangle(
 xy=3D(0,0), width=3D1, height=3D1,
 facecolor=3Dself._axisbg,
 edgecolor=3DrcParams['axes.edgecolor'],
 )
 self.axesPatch.set_figure(self.figure)
 self.axesPatch.set_transform(self.transAxes)
 self.axesPatch.set_linewidth(rcParams['axes.linewidth'])
 self.axison =3D True
 def add_artist(self, a):
 'Add any artist to the axes'
 self.artists.append(a)
 self._set_artist_props(a)
 def add_collection(self, collection):
 'add a Collection instance to Axes'
 self.collections.append(collection)
 self._set_artist_props(collection)
 collection.set_clip_box(self.bbox)
 def get_images(self):
 'return a list of Axes images contained by the Axes'
 return silent_list('AxesImage', self.images)
 def get_xscale(self):
 'return the xaxis scale string: log or linear'
 return self.scaled[self.transData.get_funcx().get_type()]
 def get_yscale(self):
 'return the yaxis scale string: log or linear'
 return self.scaled[self.transData.get_funcy().get_type()]
 def update_datalim(self, xys):
 'Update the data lim bbox with seq of xy tups'
 # if no data is set currently, the bbox will ignore it's
 # limits and set the bound to be the bounds of the xydata.
 # Otherwise, it will compute the bounds of it's current data
 # and the data in xydata
 self.dataLim.update(xys, not self.has_data())
 def update_datalim_numerix(self, x, y):
 'Update the data lim bbox with seq of xy tups'
 # if no data is set currently, the bbox will ignore it's
 # limits and set the bound to be the bounds of the xydata.
 # Otherwise, it will compute the bounds of it's current data
 # and the data in xydata
 #print type(x), type(y)
 self.dataLim.update_numerix(x, y, not self.has_data())
 def add_line(self, l):
 'Add a line to the list of plot lines'
 self._set_artist_props(l)
 l.set_clip_box(self.bbox)
 xdata =3D l.get_xdata(valid_only=3DTrue)
 ydata =3D l.get_ydata(valid_only=3DTrue)
 if l.get_transform() !=3D self.transData:
 xys =3D self._get_verts_in_data_coords(
 l.get_transform(), zip(xdata, ydata))
 xdata =3D array([x for x,y in xys])
 ydata =3D array([y for x,y in xys])
 self.update_datalim_numerix( xdata, ydata )
 #self.update_datalim(zip(xdata, ydata))
 label =3D l.get_label()
 if not label: l.set_label('line%d'%len(self.lines))
 self.lines.append(l)
 def _get_verts_in_data_coords(self, trans, xys):
 if trans =3D=3D self.transData:
 return xys
 # data is not in axis data units. We must transform it to
 # display and then back to data to get it in data units
 xys =3D trans.seq_xy_tups(xys)
 return [ self.transData.inverse_xy_tup(xy) for xy in xys]
 def add_patch(self, p):
 """
 Add a patch to the list of Axes patches; the clipbox will be
 set to the Axes clipping box. If the transform is not set, it
 wil be set to self.transData.
 """
 self._set_artist_props(p)
 p.set_clip_box(self.bbox)
 xys =3D self._get_verts_in_data_coords(
 p.get_transform(), p.get_verts())
 #for x,y in xys: print x,y
 self.update_datalim(xys)
 self.patches.append(p)
 def add_table(self, tab):
 'Add a table instance to the list of axes tables'
 self._set_artist_props(tab)
 self.tables.append(tab)
 def autoscale_view(self):
 'autoscale the view limits using the data limits'
 # if image data only just use the datalim
 if not self._autoscaleon: return
 if (len(self.images)>0 and
 len(self.lines)=3D=3D0 and
 len(self.patches)=3D=3D0):
 self.set_xlim(self.dataLim.intervalx().get_bounds())
 self.set_ylim(self.dataLim.intervaly().get_bounds())
 return
 locator =3D self.xaxis.get_major_locator()
 self.set_xlim(locator.autoscale())
 locator =3D self.yaxis.get_major_locator()
 self.set_ylim(locator.autoscale())
 if self._aspect =3D=3D 'equal': self.set_aspect('equal')
 def quiver(self, U, V, *args, **kwargs ):
 """
 QUIVER( X, Y, U, V )
 QUIVER( U, V )
 QUIVER( X, Y, U, V, S)
 QUIVER( U, V, S )
 QUIVER( ..., color=3DNone, width=3D1.0, cmap=3DNone,norm=3DNone =
)
 Make a vector plot (U, V) with arrows on a grid (X, Y)
 The optional arguments color and width are used to specify the =
color and width
 of the arrow. color can be an array of colors in which case the =
arrows can be
 colored according to another dataset.
 If cm is specied and color is None, the colormap is used to give =
a color
 according to the vector's length.
 If color is a scalar field, the colormap is used to map the =
scalar to a color
 If a colormap is specified and color is an array of color =
triplets, then the
 colormap is ignored
 width is a scalar that controls the width of the arrows
 if S is specified it is used to scale the vectors. Use S=3D0 to =
disable automatic
 scaling.
 If S!=3D0, vectors are scaled to fit within the grid and then =
are multiplied by S.
 """
 if not self._hold: self.cla()
 do_scale =3D True
 S =3D 1.0
 if len(args)=3D=3D0:
 # ( U, V )
 U =3D asarray(U)
 V =3D asarray(V)
 X,Y =3D meshgrid( arange(U.shape[1]), arange(U.shape[0]) )
 elif len(args)=3D=3D1:
 # ( U, V, S )
 U =3D asarray(U)
 V =3D asarray(V)
 X,Y =3D meshgrid( arange(U.shape[1]), arange(U.shape[0]) )
 S =3D float(args[0])
 do_scale =3D ( S !=3D 0.0 )
 elif len(args)=3D=3D2:
 # ( X, Y, U, V )
 X =3D asarray(U)
 Y =3D asarray(V)
 U =3D asarray(args[0])
 V =3D asarray(args[1])
 elif len(args)=3D=3D3:
 # ( X, Y, U, V )
 X =3D asarray(U)
 Y =3D asarray(V)
 U =3D asarray(args[0])
 V =3D asarray(args[1])
 S =3D float(args[2])
 do_scale =3D ( S !=3D 0.0 )
 assert U.shape =3D=3D V.shape
 assert X.shape =3D=3D Y.shape
 assert U.shape =3D=3D X.shape
 arrows =3D []
 N =3D sqrt( U**2+V**2 )
 if do_scale:
 Nmax =3D maximum.reduce(maximum.reduce(N)) or 1 # account =
for div by zero
 U =3D U*(S/Nmax)
 V =3D V*(S/Nmax)
 N =3D N*Nmax
 alpha =3D kwargs.get('alpha', 1.0)
 width =3D kwargs.get('width', 0.25)
 norm =3D kwargs.get('norm', None)
 cmap =3D kwargs.get('cmap', None)
 vmin =3D kwargs.get('vmin', None)
 vmax =3D kwargs.get('vmax', None)
 color =3D kwargs.get('color', None)
 shading =3D kwargs.get('shading', 'faceted')
 C =3D None
 I,J =3D U.shape
 if color is not None and not looks_like_color(color):
 clr =3D asarray(color)
 if clr.shape=3D=3DU.shape:
 C =3D array([ clr[i,j] for i in xrange(I) for j in =
xrange(J)])
 elif clr.shape =3D=3D () and color:
 # a scalar (1, True,...)
 C =3D array([ N[i,j] for i in xrange(I) for j in =
xrange(J)])
 else:
 color =3D (0.,0.,0.,1.)
 elif color is None:
 color =3D (0.,0.,0.,1.)
 else:
 color =3D colorConverter.to_rgba( color, alpha )
 arrows =3D [ Arrow(X[i,j],Y[i,j],U[i,j],V[i,j],0.1*S =
).get_verts()
 for i in xrange(I) for j in xrange(J) ]
 collection =3D PolyCollection(
 arrows,
 edgecolors =3D 'None',
 facecolors =3D (color,),
 antialiaseds =3D (1,),
 linewidths =3D (width,),
 )
 if C is not None:
 collection.set_array( C )
 else:
 collection.set_facecolor( (color,) )
 collection.set_cmap(cmap)
 collection.set_norm(norm)
 if norm is not None:
 collection.set_clim( vmin, vmax )
 self.add_collection( collection )
 lims =3D asarray(arrows)
 _max =3D maximum.reduce( maximum.reduce( lims ))
 _min =3D minimum.reduce( minimum.reduce( lims ))
 self.update_datalim( [ tuple(_min), tuple(_max) ] )
 self.autoscale_view()
 return arrows
 def bar(self, left, height, width=3D0.8, bottom=3D0,
 color=3D'b', yerr=3DNone, xerr=3DNone, ecolor=3D'k', =
capsize=3D3
 ):
 """
 BAR(left, height, width=3D0.8, bottom=3D0,
 color=3D'b', yerr=3DNone, xerr=3DNone, ecolor=3D'k', =
capsize=3D3)
 Make a bar plot with rectangles at
 left, left+width, 0, height
 left and height are Numeric arrays.
 Return value is a list of Rectangle patch instances
 BAR(left, height, width, bottom,
 color, yerr, xerr, capsize, yoff)
 xerr and yerr, if not None, will be used to generate =
errorbars
 on the bar chart
 color specifies the color of the bar
 ecolor specifies the color of any errorbar
 capsize determines the length in points of the error bar =
caps
 The optional arguments color, width and bottom can be either
 scalars or len(x) sequences
 This enables you to use bar as the basis for stacked bar
 charts, or candlestick plots
 """
 if not self._hold: self.cla()
 # left =3D asarray(left) - width/2
 left =3D asarray(left)
 height =3D asarray(height)
 patches =3D []
 # if color looks like a color string, an RGB tuple or a
 # scalar, then repeat it by len(x)
 if (is_string_like(color) or
 (iterable(color) and len(color)=3D=3D3 and len(left)!=3D3) =
or
 not iterable(color)):
 color =3D [color]*len(left)
 if not iterable(bottom):
 bottom =3D array([bottom]*len(left), Float)
 else:
 bottom =3D asarray(bottom)
 if not iterable(width):
 width =3D array([width]*len(left), Float)
 else:
 width =3D asarray(width)
 N =3D len(left)
 assert len(bottom)=3D=3DN, 'bar arg bottom must be len(left)'
 assert len(width)=3D=3DN, 'bar arg width must be len(left) or =
scalar'
 assert len(height)=3D=3DN, 'bar arg height must be len(left) or =
scalar'
 assert len(color)=3D=3DN, 'bar arg color must be len(left) or =
scalar'
 args =3D zip(left, bottom, width, height, color)
 for l, b, w, h, c in args:
 if h<0:
 b +=3D h
 h =3D abs(h)
 r =3D Rectangle(
 xy=3D(l, b), width=3Dw, height=3Dh,
 facecolor=3Dc,
 )
 self.add_patch(r)
 patches.append(r)
 if xerr is not None or yerr is not None:
 self.errorbar(
 left+0.5*width, bottom+height,
 yerr=3Dyerr, xerr=3Dxerr,
 fmt=3DNone, ecolor=3Decolor, capsize=3Dcapsize)
 self.autoscale_view()
 return patches
 def boxplot(self, x, notch=3D0, sym=3D'b+', vert=3D1, whis=3D1.5,
 positions=3DNone, widths=3DNone):
 """
 boxplot(x, notch=3D0, sym=3D'+', vert=3D1, whis=3D1.5,
 positions=3DNone, widths=3DNone)
 Make a box and whisker plot for each column of x.
 The box extends from the lower to upper quartile values
 of the data, with a line at the median. The whiskers
 extend from the box to show the range of the data. Flier
 points are those past the end of the whiskers.
 notch =3D 0 (default) produces a rectangular box plot.
 notch =3D 1 will produce a notched box plot
 sym (default 'b+') is the default symbol for flier points.
 Enter an empty string ('') if you don't want to show fliers.
 vert =3D 1 (default) makes the boxes vertical.
 vert =3D 0 makes horizontal boxes. This seems goofy, but
 that's how Matlab did it.
 whis (default 1.5) defines the length of the whiskers as
 a function of the inner quartile range. They extend to the
 most extreme data point within ( whis*(75%-25%) ) data range.
 positions (default 1,2,...,n) sets the horizontal positions of
 the boxes. The ticks and limits are automatically set to match
 the positions.
 widths is either a scalar or a vector and sets the width of
 each box. The default is 0.5, or 0.15*(distance between extreme
 positions) if that is smaller.
 x is a Numeric array
 Returns a list of the lines added
 """
 if not self._hold: self.cla()
 holdStatus =3D self._hold
 lines =3D []
 x =3D asarray(x)
 # if we've got a vector, reshape it
 rank =3D len(x.shape)
 if 1 =3D=3D rank:
 x.shape =3D -1, 1
 row, col =3D x.shape
 # get some plot info
 if positions is None:
 positions =3D range(1, col + 1)
 if widths is None:
 distance =3D max(positions) - min(positions)
 widths =3D distance * min(0.15, 0.5/distance)
 if isinstance(widths, float) or isinstance(widths, int):
 widths =3D ones((col,), 'd') * widths
 # loop through columns, adding each to plot
 self.hold(True)
 for i,pos in enumerate(positions):
 d =3D x[:,i]
 # get median and quartiles
 q1, med, q3 =3D prctile(d,[25,50,75])
 # get high extreme
 iq =3D q3 - q1
 hi_val =3D q3 + whis*iq
 wisk_hi =3D compress( d <=3D hi_val , d )
 if len(wisk_hi) =3D=3D 0:
 wisk_hi =3D q3
 else:
 wisk_hi =3D max(wisk_hi)
 # get low extreme
 lo_val =3D q1 - whis*iq
 wisk_lo =3D compress( d >=3D lo_val, d )
 if len(wisk_lo) =3D=3D 0:
 wisk_lo =3D q1
 else:
 wisk_lo =3D min(wisk_lo)
 # get fliers - if we are showing them
 flier_hi =3D []
 flier_lo =3D []
 flier_hi_x =3D []
 flier_lo_x =3D []
 if len(sym) !=3D 0:
 flier_hi =3D compress( d > wisk_hi, d )
 flier_lo =3D compress( d < wisk_lo, d )
 flier_hi_x =3D ones(flier_hi.shape[0]) * pos
 flier_lo_x =3D ones(flier_lo.shape[0]) * pos
 # get x locations for fliers, whisker, whisker cap and box =
sides
 box_x_min =3D pos - widths[i] * 0.5
 box_x_max =3D pos + widths[i] * 0.5
 wisk_x =3D ones(2) * pos
 cap_x_min =3D pos - widths[i] * 0.25
 cap_x_max =3D pos + widths[i] * 0.25
 cap_x =3D [cap_x_min, cap_x_max]
 # get y location for median
 med_y =3D [med, med]
 # calculate 'regular' plot
 if notch =3D=3D 0:
 # make our box vectors
 box_x =3D [box_x_min, box_x_max, box_x_max, box_x_min, =
box_x_min ]
 box_y =3D [q1, q1, q3, q3, q1 ]
 # make our median line vectors
 med_x =3D [box_x_min, box_x_max]
 # calculate 'notch' plot
 else:
 notch_max =3D med + 1.57*iq/sqrt(row)
 notch_min =3D med - 1.57*iq/sqrt(row)
 if notch_max > q3:
 notch_max =3D q3
 if notch_min < q1:
 notch_min =3D q1
 # make our notched box vectors
 box_x =3D [box_x_min, box_x_max, box_x_max, cap_x_max, =
box_x_max, box_x_max, box_x_min, box_x_min, cap_x_min, box_x_min, =
box_x_min ]
 box_y =3D [q1, q1, notch_min, med, notch_max, q3, q3, =
notch_max, med, notch_min, q1]
 # make our median line vectors
 med_x =3D [cap_x_min, cap_x_max]
 med_y =3D [med, med]
 # make a vertical plot . . .
 if 1 =3D=3D vert:
 l =3D self.plot(wisk_x, [q1, wisk_lo], 'b--',
 wisk_x, [q3, wisk_hi], 'b--',
 cap_x, [wisk_hi, wisk_hi], 'k-',
 cap_x, [wisk_lo, wisk_lo], 'k-',
 box_x, box_y, 'b-',
 med_x, med_y, 'r-',
 flier_hi_x, flier_hi, sym,
 flier_lo_x, flier_lo, sym )
 lines.extend(l)
 # or perhaps a horizontal plot
 else:
 l =3D self.plot([q1, wisk_lo], wisk_x, 'b--',
 [q3, wisk_hi], wisk_x, 'b--',
 [wisk_hi, wisk_hi], cap_x, 'k-',
 [wisk_lo, wisk_lo], cap_x, 'k-',
 box_y, box_x, 'b-',
 med_y, med_x, 'r-',
 flier_hi, flier_hi_x, sym,
 flier_lo, flier_lo_x, sym )
 lines.extend(l)
 # fix our axes/ticks up a little
 if 1 =3D=3D vert:
 setticks, setlim =3D self.set_xticks, self.set_xlim
 else:
 setticks, setlim =3D self.set_yticks, self.set_ylim
 newlimits =3D min(positions)-0.5, max(positions)+0.5
 setlim(newlimits)
 setticks(positions)
 =20
 # reset hold status
 self.hold(holdStatus)
 return lines
 def barh(self, x, y, height=3D0.8, left=3D0,
 color=3D'b', yerr=3DNone, xerr=3DNone, ecolor=3D'k', =
capsize=3D3
 ):
 """
 BARH(x, y, height=3D0.8, left=3D0,
 color=3D'b', yerr=3DNone, xerr=3DNone, ecolor=3D'k', =
capsize=3D3)
 BARH(x, y)
 The y values give the heights of the center of the bars. =
The
 x values give the length of the bars.
 Return value is a list of Rectangle patch instances
 Optional arguments
 height - the height (thickness) of the bar
 left - the x coordinate of the left side of the bar
 color specifies the color of the bar
 xerr and yerr, if not None, will be used to generate =
errorbars
 on the bar chart
 ecolor specifies the color of any errorbar
 capsize determines the length in points of the error bar =
caps
 The optional arguments color, height and left can be either
 scalars or len(x) sequences
 """
 if not self._hold: self.cla()
 # left =3D asarray(left) - width/2
 x =3D asarray(x)
 y =3D asarray(y)
 patches =3D []
 # if color looks like a color string, and RGB tuple or a
 # scalar, then repeat it by len(x)
 if (is_string_like(color) or
 (iterable(color) and len(color)=3D=3D3 and len(left)!=3D3) =
or
 not iterable(color)):
 color =3D [color]*len(x)
 if not iterable(left):
 left =3D array([left]*len(x), Float)
 else:
 left =3D asarray(left)
 if not iterable(height):
 height =3D array([height]*len(x), Float)
 else:
 height =3D asarray(height)
 N =3D len(x)
 assert len(left)=3D=3DN, 'bar arg left must be len(x)'
 assert len(height)=3D=3DN, 'bar arg height must be len(x) or =
scalar'
 assert len(y)=3D=3DN, 'bar arg y must be len(x) or scalar'
 assert len(color)=3D=3DN, 'bar arg color must be len(x) or =
scalar'
 width =3D x
 right =3D left+x
 bottom =3D y - height/2.
 args =3D zip(left, bottom, width, height, color)
 for l, b, w, h, c in args:
 if h<0:
 b +=3D h
 h =3D abs(h)
 r =3D Rectangle(
 xy=3D(l, b), width=3Dw, height=3Dh,
 facecolor=3Dc,
 )
 self.add_patch(r)
 patches.append(r)
 if xerr is not None or yerr is not None:
 self.errorbar(
 right, y,
 yerr=3Dyerr, xerr=3Dxerr,
 fmt=3DNone, ecolor=3Decolor, capsize=3Dcapsize)
 self.autoscale_view()
 return patches
 def clear(self):
 'clear the axes'
 self.cla()
 def clabel(self, CS, *args, **kwargs):
 return CS.clabel(*args, **kwargs)
 clabel.__doc__ =3D ContourSet.clabel.__doc__
 def contour(self, *args, **kwargs):
 kwargs['filled'] =3D False
 return ContourSet(self, *args, **kwargs)
 contour.__doc__ =3D ContourSet.contour_doc
 def contourf(self, *args, **kwargs):
 kwargs['filled'] =3D True
 return ContourSet(self, *args, **kwargs)
 contourf.__doc__ =3D ContourSet.contour_doc
 def cohere(self, x, y, NFFT=3D256, Fs=3D2, detrend=3Ddetrend_none,
 window=3Dwindow_hanning, noverlap=3D0, **kwargs):
 """
 COHERE(x, y, NFFT=3D256, Fs=3D2, detrend=3Ddetrend_none,
 window=3Dwindow_hanning, noverlap=3D0)
 cohere the coherence between x and y. Coherence is the =
normalized
 cross spectral density
 Cxy =3D |Pxy|^2/(Pxx*Pyy)
 The return value is (Cxy, f), where f are the frequencies of the
 coherence vector.
 See the PSD help for a description of the optional parameters.
 kwargs are applied to the lines
 Returns the tuple Cxy, freqs
 Refs: Bendat & Piersol -- Random Data: Analysis and Measurement
 Procedures, John Wiley & Sons (1986)
 """
 if not self._hold: self.cla()
 cxy, freqs =3D matplotlib.mlab.cohere(x, y, NFFT, Fs, detrend, =
window, noverlap)
 self.plot(freqs, cxy, **kwargs)
 self.set_xlabel('Frequency')
 self.set_ylabel('Coherence')
 self.grid(True)
 return cxy, freqs
 def csd(self, x, y, NFFT=3D256, Fs=3D2, detrend=3Ddetrend_none,
 window=3Dwindow_hanning, noverlap=3D0):
 """
 CSD(x, y, NFFT=3D256, Fs=3D2, detrend=3Ddetrend_none,
 window=3Dwindow_hanning, noverlap=3D0)
 The cross spectral density Pxy by Welches average periodogram =
method.
 The vectors x and y are divided into NFFT length segments. Each
 segment is detrended by function detrend and windowed by =
function
 window. The product of the direct FFTs of x and y are averaged =
over
 each segment to compute Pxy, with a scaling to correct for power =
loss
 due to windowing.
 See the PSD help for a description of the optional parameters.
 Returns the tuple Pxy, freqs. Pxy is the cross spectrum =
(complex
 valued), and 10*log10(|Pxy|) is plotted
 Refs:
 Bendat & Piersol -- Random Data: Analysis and Measurement
 Procedures, John Wiley & Sons (1986)
 """
 if not self._hold: self.cla()
 pxy, freqs =3D matplotlib.mlab.csd(x, y, NFFT, Fs, detrend, =
window, noverlap)
 pxy.shape =3D len(freqs),
 # pxy is complex
 self.plot(freqs, 10*log10(absolute(pxy)))
 self.set_xlabel('Frequency')
 self.set_ylabel('Cross Spectrum Magnitude (dB)')
 self.grid(True)
 vmin, vmax =3D self.viewLim.intervaly().get_bounds()
 intv =3D vmax-vmin
 step =3D 10*int(log10(intv))
 ticks =3D arange(math.floor(vmin), math.ceil(vmax)+1, step)
 self.set_yticks(ticks)
 return pxy, freqs
 def draw_artist(self, a):
 """
 This method can only be used after an initial draw which
 caches the renderer. It is used to efficiently update Axes
 data (axis ticks, labels, etc are not updated)
 """
 assert self._cachedRenderer is not None
 a.draw(self._cachedRenderer)
 def redraw_in_frame(self):
 """
 This method can only be used after an initial draw which
 caches the renderer. It is used to efficiently update Axes
 data (axis ticks, labels, etc are not updated)
 """
 assert self._cachedRenderer is not None
 self.draw(self._cachedRenderer, inframe=3DTrue)
 def get_renderer_cache(self):
 return self._cachedRenderer
 def draw(self, renderer=3DNone, inframe=3DFalse):
 "Draw everything (plot lines, axes, labels)"
 if renderer is None:
 renderer =3D self._cachedRenderer
 if renderer is None:
 raise RuntimeError('No renderer defined')
 if not self.get_visible(): return
 renderer.open_group('axes')
 try: self.transData.freeze() # eval the lazy objects
 except ValueError:
 print >> sys.stderr, 'data freeze value error', =
self.get_position(), self.dataLim.get_bounds(), =
self.viewLim.get_bounds()
 raise
 =20
 self.transAxes.freeze() # eval the lazy objects
 if self.axison:
 if self._frameon: self.axesPatch.draw(renderer)
 if len(self.images)=3D=3D1:
 im =3D self.images[0]
 im.draw(renderer)
 elif len(self.images)>1:
 # make a composite image blending alpha
 # list of (_image.Image, ox, oy)
 ims =3D [(im.make_image(),0,0) for im in self.images if =
im.get_visible()]
 im =3D _image.from_images(self.bbox.height(), =
self.bbox.width(), ims)
 im.is_grayscale =3D False
 l, b, w, h =3D self.bbox.get_bounds()
 renderer.draw_image(l, b, im, self.bbox)
 # axis drawing was here, where contourf etc clobbered them
 # draw axes here, so they are on top of most things
 if self._axisbelow:
 if self.axison and not inframe:
 self.xaxis.draw(renderer)
 self.yaxis.draw(renderer)
 artists =3D []
 artists.extend(self.collections)
 artists.extend(self.patches)
 artists.extend(self.lines)
 artists.extend(self.texts)
 # keep track of i to guarantee stable sort for python 2.2
 dsu =3D [ (a.zorder, i, a) for i, a in enumerate(artists)
 if not a.get_animated()]
 dsu.sort()
 for zorder, i, a in dsu:
 a.draw(renderer)
 self.title.draw(renderer)
 if 0: bbox_artist(self.title, renderer)
 # optional artists
 for a in self.artists:
 a.draw(renderer)
 if not self._axisbelow:
 if self.axison and not inframe:
 self.xaxis.draw(renderer)
 self.yaxis.draw(renderer)
 if self.legend_ is not None:
 self.legend_.draw(renderer)
 for table in self.tables:
 table.draw(renderer)
 self.transData.thaw() # release the lazy objects
 self.transAxes.thaw() # release the lazy objects
 renderer.close_group('axes')
 self._cachedRenderer =3D renderer
 def __draw_animate(self):
 # ignore for now; broken
 if self._lastRenderer is None:
 raise RuntimeError('You must first call ax.draw()')
 dsu =3D [(a.zorder, a) for a in self.animated.keys()]
 dsu.sort()
 renderer =3D self._lastRenderer
 renderer.blit()
 for tmp, a in dsu:
 a.draw(renderer)
 def errorbar(self, x, y, yerr=3DNone, xerr=3DNone,
 fmt=3D'b-', ecolor=3DNone, capsize=3D3,
 barsabove=3DFalse, **kwargs):
 """
 ERRORBAR(x, y, yerr=3DNone, xerr=3DNone,
 fmt=3D'b-', ecolor=3DNone, capsize=3D3, =
barsabove=3DFalse)
 Plot x versus y with error deltas in yerr and xerr.
 Vertical errorbars are plotted if yerr is not None
 Horizontal errorbars are plotted if xerr is not None
 xerr and yerr may be any of:
 a rank-0, Nx1 Numpy array - symmetric errorbars +/- value
 an N-element list or tuple - symmetric errorbars +/- value
 a rank-1, Nx2 Numpy array - asymmetric errorbars =
-column1/+column2
 Alternatively, x, y, xerr, and yerr can all be scalars, which
 plots a single error bar at x, y.
 fmt is the plot format symbol for y. if fmt is None, just
 plot the errorbars with no line symbols. This can be useful
 for creating a bar plot with errorbars
 ecolor is a matplotlib color arg which gives the color the
 errorbar lines; if None, use the marker color.
 capsize is the size of the error bar caps in points
 barsabove, if True, will plot the errorbars above the plot =
symbols
 - default is below
 kwargs are passed on to the plot command for the markers.
 So you can add additional key=3Dvalue pairs to control the
 errorbar markers. For example, this code makes big red
 squares with thick green edges
 >>> x,y,yerr =3D rand(3,10)
 >>> errorbar(x, y, yerr, marker=3D's',
 mfc=3D'red', mec=3D'green', ms=3D20, mew=3D4)
 mfc, mec, ms and mew are aliases for the longer property
 names, markerfacecolor, markeredgecolor, markersize and
 markeredgewith.
 Return value is a length 2 tuple. The first element is the
 Line2D instance for the y symbol lines. The second element is
 a list of error bar lines.
 """
 if not self._hold: self.cla()
 # make sure all the args are iterable arrays
 if not iterable(x): x =3D asarray([x])
 else: x =3D asarray(x)
 if not iterable(y): y =3D asarray([y])
 else: y =3D asarray(y)
 if xerr is not None:
 if not iterable(xerr): xerr =3D asarray([xerr])
 else: xerr =3D asarray(xerr)
 if yerr is not None:
 if not iterable(yerr): yerr =3D asarray([yerr])
 else: yerr =3D asarray(yerr)
 l0 =3D None
 if barsabove and fmt is not None:
 l0, =3D self.plot(x,y,fmt,**kwargs)
 caplines =3D []
 barlines =3D []
 if xerr is not None:
 if len(xerr.shape) =3D=3D 1:
 left =3D x-xerr
 right =3D x+xerr
 else:
 left =3D x-xerr[0]
 right =3D x+xerr[1]
 barlines.extend( self.hlines(y, x, left) )
 barlines.extend( self.hlines(y, x, right) )
 caplines.extend( self.plot(left, y, '|', ms=3D2*capsize) )
 caplines.extend( self.plot(right, y, '|', ms=3D2*capsize) )
 if yerr is not None:
 if len(yerr.shape) =3D=3D 1:
 lower =3D y-yerr
 upper =3D y+yerr
 else:
 lower =3D y-yerr[0]
 upper =3D y+yerr[1]
 barlines.extend( self.vlines(x, y, upper ) )
 barlines.extend( self.vlines(x, y, lower ) )
 caplines.extend( self.plot(x, lower, '_', ms=3D2*capsize) )
 caplines.extend( self.plot(x, upper, '_', ms=3D2*capsize) )
 if not barsabove and fmt is not None:
 l0, =3D self.plot(x,y,fmt,**kwargs)
 if ecolor is None and l0 is None:
 ecolor =3D rcParams['lines.color']
 elif ecolor is None:
 ecolor =3D l0.get_color()
 for l in barlines:
 l.set_color(ecolor)
 for l in caplines:
 l.set_color(ecolor)
 l.set_markerfacecolor(ecolor)
 l.set_markeredgecolor(ecolor)
 self.autoscale_view()
 ret =3D silent_list('Line2D errorbar', caplines+barlines)
 return (l0, ret)
 def fill(self, *args, **kwargs):
 """
 FILL(*args, **kwargs)
 plot filled polygons. *args is a variable length argument, =
allowing
 for multiple x,y pairs with an optional color format string; see =
plot
 for details on the argument parsing. For example, all of the
 following are legal, assuming a is the Axis instance:
 ax.fill(x,y) # plot polygon with vertices at x,y
 ax.fill(x,y, 'b' ) # plot polygon with vertices at x,y in =
blue
 An arbitrary number of x, y, color groups can be specified, as =
in
 ax.fill(x1, y1, 'g', x2, y2, 'r')
 Return value is a list of patches that were added
 The same color strings that plot supports are supported by the =
fill
 format string.
 The kwargs that are can be used to set line properties (any
 property that has a set_* method). You can use this to set edge
 color, face color, etc.
 """
 if not self._hold: self.cla()
 patches =3D []
 for poly in self._get_patches_for_fill(*args, **kwargs):
 self.add_patch( poly )
 patches.append( poly )
 self.autoscale_view()
 return patches
 def get_axis_bgcolor(self):
 'Return the axis background color'
 return self._axisbg
 def get_child_artists(self):
 """
 Return a list of artists the axes contains. Deprecated
 """
 artists =3D [self.title, self.axesPatch, self.xaxis, self.yaxis]
 artists.extend(self.lines)
 artists.extend(self.patches)
 artists.extend(self.texts)
 artists.extend(self.collections)
 if self.legend_ is not None:
 artists.append(self.legend_)
 return silent_list('Artist', artists)
 def get_frame(self):
 'Return the axes Rectangle frame'
 return self.axesPatch
 def get_legend(self):
 'Return the Legend instance, or None if no legend is defined'
 return self.legend_
 def get_lines(self):
 'Return a list of lines contained by the Axes'
 return silent_list('Line2D', self.lines)
 def get_xaxis(self):
 'Return the XAxis instance'
 return self.xaxis
 def get_xgridlines(self):
 'Get the x grid lines as a list of Line2D instances'
 return silent_list('Line2D xgridline', =
self.xaxis.get_gridlines())
 def get_xlim(self):
 'Get the x axis range [xmin, xmax]'
 return self.viewLim.intervalx().get_bounds()
 def get_xticklabels(self):
 'Get the xtick labels as a list of Text instances'
 return silent_list('Text xticklabel', =
self.xaxis.get_ticklabels())
 def get_xticklines(self):
 'Get the xtick lines as a list of Line2D instances'
 return silent_list('Text xtickline', self.xaxis.get_ticklines())
 def get_xticks(self):
 'Return the x ticks as a list of locations'
 return self.xaxis.get_ticklocs()
 def get_yaxis(self):
 'Return the YAxis instance'
 return self.yaxis
 def get_ylim(self):
 'Get the y axis range [ymin, ymax]'
 return self.viewLim.intervaly().get_bounds()
 def get_ygridlines(self):
 'Get the y grid lines as a list of Line2D instances'
 return silent_list('Line2D ygridline', =
self.yaxis.get_gridlines())
 def get_yticklabels(self):
 'Get the ytick labels as a list of Text instances'
 return silent_list('Text yticklabel', =
self.yaxis.get_ticklabels())
 def get_yticklines(self):
 'Get the ytick lines as a list of Line2D instances'
 return silent_list('Line2D ytickline', =
self.yaxis.get_ticklines())
 def get_yticks(self):
 'Return the y ticks as a list of locations'
 return self.yaxis.get_ticklocs()
 def get_frame_on(self):
 """
 Get whether the axes rectangle patch is drawn
 """
 return self._frameon
 def get_navigate(self):
 """
 Get whether the axes responds to navigation commands
 """
 return self._navigate
 def get_axisbelow(self):
 """
 Get whether axist below is true or not
 """
 return self._axisbelow
 def get_autoscale_on(self):
 """
 Get whether autoscaling is applied on plot commands
 """
 return self._autoscaleon
 def grid(self, b=3DNone):
 """
 Set the axes grids on or off; b is a boolean
 if b is None, toggle the grid state
 """
 self.xaxis.grid(b)
 self.yaxis.grid(b)
 def hist(self, x, bins=3D10, normed=3D0, bottom=3D0,
 orientation=3D'vertical', width=3DNone, **kwargs):
 """
 HIST(x, bins=3D10, normed=3D0, bottom=3D0, =
orientiation=3D'vertical', **kwargs)
 Compute the histogram of x. bins is either an integer number of
 bins or a sequence giving the bins. x are the data to be =
binned.
 The return values is (n, bins, patches)
 If normed is true, the first element of the return tuple will
 be the counts normalized to form a probability density, ie,
 n/(len(x)*dbin)
 orientation =3D 'horizontal' | 'vertical'. If horizontal, barh
 will be used and the "bottom" kwarg will be the left.
 width: the width of the bars. If None, automatically compute
 the width.
 kwargs are used to update the properties of the
 hist bars
 """
 if not self._hold: self.cla()
 n,bins =3D matplotlib.mlab.hist(x, bins, normed)
 if width is None: width =3D 0.9*(bins[1]-bins[0])
 if orienta...
 
[truncated message content]
From: <da...@eg...> - 2005年11月24日 00:52:45
On Nov 23, 2005, at 12:20 PM, Ravikiran Rajagopal wrote:
> After application of Daishi Harada's patch on 0.85, I tried to use it 
> with
> SciPy core SVN from yesterday and get rather strange results:
I'm sorry you're having troubles with the patch.
Unfortunately, I can't seem to recreate your problem.
I realize "works for me" isn't a particularly useful
response, but I'm afraid that's the best I can do
for now - and I'll be away again for Thanksgiving
until next week.
FWIW, I'm using the CVS matplotlib with the wx backend,
and the new scipy w/atlas.
d

Showing 3 results of 3

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /