|
From: <jd...@us...> - 2007-07-17 22:15:45
|
Revision: 3554
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3554&view=rev
Author: jdh2358
Date: 2007-07-17 15:15:44 -0700 (Tue, 17 Jul 2007)
Log Message:
-----------
recleanup of axes imports
Modified Paths:
--------------
trunk/matplotlib/README
trunk/matplotlib/examples/agg_test.py
trunk/matplotlib/lib/matplotlib/__init__.py
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/setup.py
Modified: trunk/matplotlib/README
===================================================================
--- trunk/matplotlib/README 2007-07-17 16:37:14 UTC (rev 3553)
+++ trunk/matplotlib/README 2007-07-17 22:15:44 UTC (rev 3554)
@@ -54,8 +54,8 @@
AUTHOR
- John D. Hunter <jdh...@ac...>
- Copyright (c) 2002-2004 John D. Hunter; All Rights Reserved.
+ John D. Hunter <jd...@gm...>
+ Copyright (c) 2002-2007 John D. Hunter; All Rights Reserved.
Jeremy O'Donoghue wrote the wx backend
Modified: trunk/matplotlib/examples/agg_test.py
===================================================================
--- trunk/matplotlib/examples/agg_test.py 2007-07-17 16:37:14 UTC (rev 3553)
+++ trunk/matplotlib/examples/agg_test.py 2007-07-17 22:15:44 UTC (rev 3554)
@@ -106,39 +106,42 @@
renderer.color_rgba8( white )
agg.render_scanlines_rgba(rasterizer, scanline, renderer);
-## Copy a rectangle from the buffer the rectangle defined by
-## x0,y0->x1,y1 and paste it at xdest, ydest
-x0, y0 = 10, 50
-x1, y1 = 110, 190
-xdest, ydest = 350, 200
+if 0:
+ ## Copy a rectangle from the buffer the rectangle defined by
+ ## x0,y0->x1,y1 and paste it at xdest, ydest
+ x0, y0 = 10, 50
+ x1, y1 = 110, 190
+ xdest, ydest = 350, 200
-widthr, heightr = x1-x0, y1-y0
-strider = widthr*4
-copybuffer = agg.buffer(widthr, heightr, strider)
-rbufcopy = agg.rendering_buffer()
-rbufcopy.attachb(copybuffer)
-pfcopy = agg.pixel_format_rgba(rbufcopy)
-rbasecopy = agg.renderer_base_rgba(pfcopy)
+ widthr, heightr = x1-x0, y1-y0
+ strider = widthr*4
+ copybuffer = agg.buffer(widthr, heightr, strider)
-rect = agg.rect(x0, y0, x1, y1)
-print rect.is_valid()
-rectp = agg.rectPtr(rect)
-#print dir(rbasecopy)
-# agg is funny about the arguments to copy from; the last 2 args are
-# dx, dy. If the src and dest buffers are the same size and you omit
-# the dx and dy args, the position of the copy in the dest buffer is
-# the same as in the src. Since our dest buffer is smaller than our
-# src buffer, we have to offset the location by -x0, -y0
-rbasecopy.copy_from(rbuf, rect, -x0, -y0);
+ rbufcopy = agg.rendering_buffer()
+ rbufcopy.attachb(copybuffer)
+ pfcopy = agg.pixel_format_rgba(rbufcopy)
+ rbasecopy = agg.renderer_base_rgba(pfcopy)
-# paste the rectangle at a new location xdest, ydest
-rbase.copy_from(rbufcopy, None, xdest, ydest);
+ rect = agg.rect(x0, y0, x1, y1)
+ print rect.is_valid()
+ rectp = agg.rectPtr(rect)
+ #print dir(rbasecopy)
+ # agg is funny about the arguments to copy from; the last 2 args are
+ # dx, dy. If the src and dest buffers are the same size and you omit
+ # the dx and dy args, the position of the copy in the dest buffer is
+ # the same as in the src. Since our dest buffer is smaller than our
+ # src buffer, we have to offset the location by -x0, -y0
+ rbasecopy.copy_from(rbuf, rect, -x0, -y0);
+ # paste the rectangle at a new location xdest, ydest
+ rbase.copy_from(rbufcopy, None, xdest, ydest);
+
+
## Display it with PIL
s = buffer.to_string()
print len(s)
Modified: trunk/matplotlib/lib/matplotlib/__init__.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/__init__.py 2007-07-17 16:37:14 UTC (rev 3553)
+++ trunk/matplotlib/lib/matplotlib/__init__.py 2007-07-17 22:15:44 UTC (rev 3554)
@@ -801,8 +801,6 @@
"""
pass
-
-
class Namespace:
"""
A class which takes a list of modules and creates an object with
@@ -832,3 +830,4 @@
mod = getattr(basemod, name)
setattr(self, name, mod)
+
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2007-07-17 16:37:14 UTC (rev 3553)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2007-07-17 22:15:44 UTC (rev 3554)
@@ -8,11 +8,32 @@
import matplotlib
rcParams = matplotlib.rcParams
-# import a bunch of matplotlib modules into a single namespace
-mpl = matplotlib.Importer("""artist, agg, axis, cbook, collections, colors,
- contour, dates, font_manager, image, legend, lines, mlab, cm,
- patches, quiver, table, text, ticker, transforms""")
+from matplotlib import artist as martist
+from matplotlib import agg
+from matplotlib import axis as maxis
+from matplotlib import cbook
+from matplotlib import collections as mcoll
+from matplotlib import colors as mcolors
+from matplotlib import contour as mcontour
+from matplotlib import dates as mdates
+from matplotlib import font_manager
+from matplotlib import image as mimage
+from matplotlib import legend as mlegend
+from matplotlib import lines as mlines
+from matplotlib import mlab
+from matplotlib import cm
+from matplotlib import patches as mpatches
+from matplotlib import quiver as mquiver
+from matplotlib import table as mtable
+from matplotlib import text as mtext
+from matplotlib import ticker as mticker
+from matplotlib import transforms as mtrans
+iterable = cbook.iterable
+is_string_like = cbook.is_string_like
+
+
+
def delete_masked_points(*args):
"""
Find all masked points in a set of arguments, and return
@@ -35,9 +56,11 @@
return args
mask = reduce(ma.mask_or, masks)
margs = []
+ is_string_like = mpl_cbook.is_string_like
+ iterable = mpl_cbook.iterable
for x in args:
- if (not mpl.cbook.is_string_like(x)
- and mpl.cbook.iterable(x)
+ if (not is_string_like(x)
+ and iterable(x)
and len(x) == len(mask)):
if (hasattr(x, 'get_compressed_copy')):
compressed_x = x.get_compressed_copy(mask)
@@ -69,7 +92,7 @@
# Is fmt just a colorspec?
try:
- color = mpl.colors.colorConverter.to_rgb(fmt)
+ color = mcolors.colorConverter.to_rgb(fmt)
return linestyle, marker, color # Yes.
except ValueError:
pass # No, not just a color.
@@ -89,17 +112,17 @@
chars = [c for c in fmt]
for c in chars:
- if mpl.lines.lineStyles.has_key(c):
+ if mlines.lineStyles.has_key(c):
if linestyle is not None:
raise ValueError(
'Illegal format string "%s"; two linestyle symbols' % fmt)
linestyle = c
- elif mpl.lines.lineMarkers.has_key(c):
+ elif mlines.lineMarkers.has_key(c):
if marker is not None:
raise ValueError(
'Illegal format string "%s"; two marker symbols' % fmt)
marker = c
- elif mpl.colors.colorConverter.colors.has_key(c):
+ elif mcolors.colorConverter.colors.has_key(c):
if color is not None:
raise ValueError(
'Illegal format string "%s"; two color symbols' % fmt)
@@ -240,7 +263,7 @@
if multicol:
for j in range(y.shape[1]):
color = self._get_next_cycle_color()
- seg = mpl.lines.Line2D(x, y[:,j],
+ seg = mlines.Line2D(x, y[:,j],
color = color,
axes=self.axes,
)
@@ -248,7 +271,7 @@
ret.append(seg)
else:
color = self._get_next_cycle_color()
- seg = mpl.lines.Line2D(x, y,
+ seg = mlines.Line2D(x, y,
color = color,
axes=self.axes,
)
@@ -259,7 +282,7 @@
def _plot_2_args(self, tup2, **kwargs):
ret = []
- if mpl.cbook.is_string_like(tup2[1]):
+ if is_string_like(tup2[1]):
assert self.command == 'plot', 'fill needs at least 2 non-string arguments'
y, fmt = tup2
@@ -271,7 +294,7 @@
_color = color
if _color is None:
_color = self._get_next_cycle_color()
- seg = mpl.lines.Line2D(x, y,
+ seg = mlines.Line2D(x, y,
color=_color,
linestyle=linestyle, marker=marker,
axes=self.axes,
@@ -293,7 +316,7 @@
def makeline(x, y):
color = self._get_next_cycle_color()
- seg = mpl.lines.Line2D(x, y,
+ seg = mlines.Line2D(x, y,
color=color,
axes=self.axes,
)
@@ -302,7 +325,7 @@
def makefill(x, y):
facecolor = self._get_next_cycle_color()
- seg = mpl.patches.Polygon(zip(x, y),
+ seg = mpatches.Polygon(zip(x, y),
facecolor = facecolor,
fill=True,
)
@@ -333,7 +356,7 @@
_color = color
if _color is None:
_color = self._get_next_cycle_color()
- seg = mpl.lines.Line2D(x, y,
+ seg = mlines.Line2D(x, y,
color=_color,
linestyle=linestyle, marker=marker,
axes=self.axes,
@@ -343,7 +366,7 @@
def makefill(x, y):
facecolor = color
- seg = mpl.patches.Polygon(zip(x, y),
+ seg = mpatches.Polygon(zip(x, y),
facecolor = facecolor,
fill=True,
)
@@ -377,13 +400,13 @@
remaining = []
continue
if len(remaining)==3:
- if not mpl.cbook.is_string_like(remaining[2]):
+ if not is_string_like(remaining[2]):
raise ValueError, 'third arg must be a format string'
for seg in self._plot_3_args(remaining, **kwargs):
yield seg
remaining=[]
continue
- if mpl.cbook.is_string_like(remaining[2]):
+ if is_string_like(remaining[2]):
for seg in self._plot_3_args(remaining[:3], **kwargs):
yield seg
remaining=remaining[3:]
@@ -392,15 +415,15 @@
yield seg
remaining=remaining[2:]
-ValueType=type(mpl.transforms.zero())
+ValueType=type(mtrans.zero())
def makeValue(v):
if type(v) == ValueType:
return v
else:
- return mpl.transforms.Value(v)
+ return mtrans.Value(v)
-class Axes(mpl.artist.Artist):
+class Axes(martist.Artist):
"""
The Axes contains most of the figure elements: Axis, Tick, Line2D,
Text, Polygon etc, and sets the coordinate system
@@ -413,8 +436,8 @@
"""
- scaled = {mpl.transforms.IDENTITY : 'linear',
- mpl.transforms.LOG10 : 'log',
+ scaled = {mtrans.IDENTITY : 'linear',
+ mtrans.LOG10 : 'log',
}
def __str__(self):
@@ -463,7 +486,7 @@
yticks: sequence of floats
"""
- mpl.artist.Artist.__init__(self)
+ martist.Artist.__init__(self)
self._position = map(makeValue, rect)
self._originalPosition = rect
self.set_axes(self)
@@ -506,7 +529,7 @@
self.set_navigate(True)
self.set_navigate_mode(None)
- if len(kwargs): mpl.artist.setp(self, **kwargs)
+ if len(kwargs): martist.setp(self, **kwargs)
if self.xaxis is not None:
self._xcid = self.xaxis.callbacks.connect('units finalize', self.relim)
@@ -521,8 +544,8 @@
def _init_axis(self):
"move this out of __init__ because non-separable axes don't use it"
- self.xaxis = mpl.axis.XAxis(self)
- self.yaxis = mpl.axis.YAxis(self)
+ self.xaxis = maxis.XAxis(self)
+ self.yaxis = maxis.YAxis(self)
def sharex_foreign(self, axforeign):
@@ -594,7 +617,7 @@
ACCEPTS: a Figure instance
"""
- mpl.artist.Artist.set_figure(self, fig)
+ martist.Artist.set_figure(self, fig)
l, b, w, h = self._position
xmin = fig.bbox.ll().x()
@@ -609,8 +632,8 @@
self.top = (b+h)*figh
- Bbox = mpl.transforms.Bbox
- Point = mpl.transforms.Point
+ Bbox = mtrans.Bbox
+ Point = mtrans.Point
self.bbox = Bbox(
Point(self.left, self.bottom),
Point(self.right, self.top ),
@@ -625,10 +648,10 @@
"""
- one = mpl.transforms.one
- zero = mpl.transforms.zero
- Point = mpl.transforms.Point
- Bbox = mpl.transforms.Bbox
+ one = mtrans.one
+ zero = mtrans.zero
+ Point = mtrans.Point
+ Bbox = mtrans.Bbox
if self._sharex is not None:
left=self._sharex.viewLim.ll().x()
right=self._sharex.viewLim.ur().x()
@@ -645,12 +668,12 @@
self.viewLim = Bbox(Point(left, bottom), Point(right, top))
- self.dataLim = mpl.transforms.unit_bbox()
+ self.dataLim = mtrans.unit_bbox()
- self.transData = mpl.transforms.get_bbox_transform(
+ self.transData = mtrans.get_bbox_transform(
self.viewLim, self.bbox)
- self.transAxes = mpl.transforms.get_bbox_transform(
- mpl.transforms.unit_bbox(), self.bbox)
+ self.transAxes = mtrans.get_bbox_transform(
+ mtrans.unit_bbox(), self.bbox)
if self._sharex:
self.transData.set_funcx(self._sharex.transData.get_funcx())
@@ -701,7 +724,7 @@
self.yaxis.cla()
self.dataLim.ignore(1)
- self.callbacks = mpl.cbook.CallbackRegistry(('xlim_changed', 'ylim_changed'))
+ self.callbacks = cbook.CallbackRegistry(('xlim_changed', 'ylim_changed'))
if self._sharex is not None:
self.xaxis.major = self._sharex.xaxis.major
@@ -726,8 +749,8 @@
self._autoscaleon = True
self.grid(self._gridOn)
- props = mpl.font_manager.FontProperties(size=rcParams['axes.titlesize'])
- self.title = mpl.text.Text(
+ props = font_manager.FontProperties(size=rcParams['axes.titlesize'])
+ self.title = mtext.Text(
x=0.5, y=1.02, text='',
fontproperties=props,
verticalalignment='bottom',
@@ -738,7 +761,7 @@
self._set_artist_props(self.title)
- self.axesPatch = mpl.patches.Rectangle(
+ self.axesPatch = mpatches.Rectangle(
xy=(0,0), width=1, height=1,
facecolor=self._axisbg,
edgecolor=rcParams['axes.edgecolor'],
@@ -746,7 +769,7 @@
self.axesPatch.set_figure(self.figure)
self.axesPatch.set_transform(self.transAxes)
self.axesPatch.set_linewidth(rcParams['axes.linewidth'])
- self.axesFrame = mpl.lines.Line2D((0,1,1,0,0), (0,0,1,1,0),
+ self.axesFrame = mlines.Line2D((0,1,1,0,0), (0,0,1,1,0),
linewidth=rcParams['axes.linewidth'],
color=rcParams['axes.edgecolor'],
figure=self.figure)
@@ -840,7 +863,7 @@
"""
ACCEPTS: ['C', 'SW', 'S', 'SE', 'E', 'NE', 'N', 'NW', 'W']
"""
- if anchor in mpl.transforms.PBox.coefs.keys() or len(anchor) == 2:
+ if anchor in mtrans.PBox.coefs.keys() or len(anchor) == 2:
self._anchor = anchor
else:
raise ValueError('argument must be among %s' %
@@ -880,7 +903,7 @@
if data_ratio is None:
data_ratio = ysize/xsize
box_aspect = A * data_ratio
- pb = mpl.transforms.PBox(self._originalPosition)
+ pb = mtrans.PBox(self._originalPosition)
pb1 = pb.shrink_to_aspect(box_aspect, fig_aspect)
self.set_position(pb1.anchor(self._anchor), 'active')
return
@@ -953,7 +976,7 @@
kwargs are passed on to set_xlim and set_ylim -- see their
docstrings for details
'''
- if len(v)==1 and mpl.cbook.is_string_like(v[0]):
+ if len(v)==1 and is_string_like(v[0]):
s = v[0].lower()
if s=='on': self.set_axis_on()
elif s=='off': self.set_axis_off()
@@ -1020,11 +1043,11 @@
def get_images(self):
'return a list of Axes images contained by the Axes'
- return mpl.cbook.silent_list('AxesImage', self.images)
+ return cbook.silent_list('AxesImage', self.images)
def get_lines(self):
'Return a list of lines contained by the Axes'
- return mpl.cbook.silent_list('Line2D', self.lines)
+ return cbook.silent_list('Line2D', self.lines)
def get_xaxis(self):
'Return the XAxis instance'
@@ -1032,12 +1055,12 @@
def get_xgridlines(self):
'Get the x grid lines as a list of Line2D instances'
- return mpl.cbook.silent_list('Line2D xgridline', self.xaxis.get_gridlines())
+ return cbook.silent_list('Line2D xgridline', self.xaxis.get_gridlines())
def get_xticklines(self):
'Get the xtick lines as a list of Line2D instances'
- return mpl.cbook.silent_list('Text xtickline', self.xaxis.get_ticklines())
+ return cbook.silent_list('Text xtickline', self.xaxis.get_ticklines())
def get_yaxis(self):
@@ -1046,11 +1069,11 @@
def get_ygridlines(self):
'Get the y grid lines as a list of Line2D instances'
- return mpl.cbook.silent_list('Line2D ygridline', self.yaxis.get_gridlines())
+ return cbook.silent_list('Line2D ygridline', self.yaxis.get_gridlines())
def get_yticklines(self):
'Get the ytick lines as a list of Line2D instances'
- return mpl.cbook.silent_list('Line2D ytickline', self.yaxis.get_ticklines())
+ return cbook.silent_list('Line2D ytickline', self.yaxis.get_ticklines())
#### Adding and tracking artists
@@ -1265,7 +1288,7 @@
im.draw(renderer)
else:
# make a composite image blending alpha
- # list of (mpl.image.Image, ox, oy)
+ # list of (mimage.Image, ox, oy)
mag = renderer.get_image_magnification()
@@ -1273,7 +1296,7 @@
for im in self.images if im.get_visible()]
- im = mpl.image.from_images(self.bbox.height()*mag,
+ im = mimage.from_images(self.bbox.height()*mag,
self.bbox.width()*mag,
ims)
im.is_grayscale = False
@@ -1398,7 +1421,7 @@
if len(kwargs): b = True
self.xaxis.grid(b, **kwargs)
self.yaxis.grid(b, **kwargs)
- grid.__doc__ = mpl.cbook.dedent(grid.__doc__) % mpl.artist.kwdocd
+ grid.__doc__ = cbook.dedent(grid.__doc__) % martist.kwdocd
def ticklabel_format(self, **kwargs):
"""
@@ -1499,7 +1522,7 @@
ACCEPTS: len(2) sequence of floats
"""
- if xmax is None and mpl.cbook.iterable(xmin):
+ if xmax is None and iterable(xmin):
xmin,xmax = xmin
@@ -1513,11 +1536,11 @@
if xmin is None: xmin = old_xmin
if xmax is None: xmax = old_xmax
- if (self.transData.get_funcx().get_type()==mpl.transforms.LOG10
+ if (self.transData.get_funcx().get_type()==mtrans.LOG10
and min(xmin, xmax)<=0):
raise ValueError('Cannot set nonpositive limits with log transform')
- xmin, xmax = mpl.transforms.nonsingular(xmin, xmax, increasing=False)
+ xmin, xmax = mtrans.nonsingular(xmin, xmax, increasing=False)
self.viewLim.intervalx().set_bounds(xmin, xmax)
if emit: self.callbacks.process('xlim_changed', self)
@@ -1549,19 +1572,19 @@
#if subsx is None: subsx = range(2, basex)
assert(value.lower() in ('log', 'linear', ))
if value == 'log':
- self.xaxis.set_major_locator(mpl.ticker.LogLocator(basex))
- self.xaxis.set_major_formatter(mpl.ticker.LogFormatterMathtext(basex))
- self.xaxis.set_minor_locator(mpl.ticker.LogLocator(basex,subsx))
- self.transData.get_funcx().set_type(mpl.transforms.LOG10)
+ self.xaxis.set_major_locator(mticker.LogLocator(basex))
+ self.xaxis.set_major_formatter(mticker.LogFormatterMathtext(basex))
+ self.xaxis.set_minor_locator(mticker.LogLocator(basex,subsx))
+ self.transData.get_funcx().set_type(mtrans.LOG10)
minx, maxx = self.get_xlim()
if min(minx, maxx)<=0:
self.autoscale_view()
elif value == 'linear':
- self.xaxis.set_major_locator(mpl.ticker.AutoLocator())
- self.xaxis.set_major_formatter(mpl.ticker.ScalarFormatter())
- self.xaxis.set_minor_locator(mpl.ticker.NullLocator())
- self.xaxis.set_minor_formatter(mpl.ticker.NullFormatter())
- self.transData.get_funcx().set_type( mpl.transforms.IDENTITY )
+ self.xaxis.set_major_locator(mticker.AutoLocator())
+ self.xaxis.set_major_formatter(mticker.ScalarFormatter())
+ self.xaxis.set_minor_locator(mticker.NullLocator())
+ self.xaxis.set_minor_formatter(mticker.NullFormatter())
+ self.transData.get_funcx().set_type( mtrans.IDENTITY )
def get_xticks(self):
'Return the x ticks as a list of locations'
@@ -1577,7 +1600,7 @@
def get_xticklabels(self):
'Get the xtick labels as a list of Text instances'
- return mpl.cbook.silent_list('Text xticklabel', self.xaxis.get_ticklabels())
+ return cbook.silent_list('Text xticklabel', self.xaxis.get_ticklabels())
def set_xticklabels(self, labels, fontdict=None, **kwargs):
"""
@@ -1592,7 +1615,7 @@
ACCEPTS: sequence of strings
"""
return self.xaxis.set_ticklabels(labels, fontdict, **kwargs)
- set_xticklabels.__doc__ = mpl.cbook.dedent(set_xticklabels.__doc__) % mpl.artist.kwdocd
+ set_xticklabels.__doc__ = cbook.dedent(set_xticklabels.__doc__) % martist.kwdocd
def get_ylim(self):
'Get the y axis range [ymin, ymax]'
@@ -1621,7 +1644,7 @@
"""
- if ymax is None and mpl.cbook.iterable(ymin):
+ if ymax is None and iterable(ymin):
ymin,ymax = ymin
if ymin is not None:
@@ -1634,11 +1657,11 @@
if ymin is None: ymin = old_ymin
if ymax is None: ymax = old_ymax
- if (self.transData.get_funcy().get_type()==mpl.transforms.LOG10
+ if (self.transData.get_funcy().get_type()==mtrans.LOG10
and min(ymin, ymax)<=0):
raise ValueError('Cannot set nonpositive limits with log transform')
- ymin, ymax = mpl.transforms.nonsingular(ymin, ymax, increasing=False)
+ ymin, ymax = mtrans.nonsingular(ymin, ymax, increasing=False)
self.viewLim.intervaly().set_bounds(ymin, ymax)
if emit: self.callbacks.process('ylim_changed', self)
@@ -1671,20 +1694,20 @@
assert(value.lower() in ('log', 'linear', ))
if value == 'log':
- self.yaxis.set_major_locator(mpl.ticker.LogLocator(basey))
- self.yaxis.set_major_formatter(mpl.ticker.LogFormatterMathtext(basey))
- self.yaxis.set_minor_locator(mpl.ticker.LogLocator(basey,subsy))
- self.transData.get_funcy().set_type(mpl.transforms.LOG10)
+ self.yaxis.set_major_locator(mticker.LogLocator(basey))
+ self.yaxis.set_major_formatter(mticker.LogFormatterMathtext(basey))
+ self.yaxis.set_minor_locator(mticker.LogLocator(basey,subsy))
+ self.transData.get_funcy().set_type(mtrans.LOG10)
miny, maxy = self.get_ylim()
if min(miny, maxy)<=0:
self.autoscale_view()
elif value == 'linear':
- self.yaxis.set_major_locator(mpl.ticker.AutoLocator())
- self.yaxis.set_major_formatter(mpl.ticker.ScalarFormatter())
- self.yaxis.set_minor_locator(mpl.ticker.NullLocator())
- self.yaxis.set_minor_formatter(mpl.ticker.NullFormatter())
- self.transData.get_funcy().set_type( mpl.transforms.IDENTITY )
+ self.yaxis.set_major_locator(mticker.AutoLocator())
+ self.yaxis.set_major_formatter(mticker.ScalarFormatter())
+ self.yaxis.set_minor_locator(mticker.NullLocator())
+ self.yaxis.set_minor_formatter(mticker.NullFormatter())
+ self.transData.get_funcy().set_type( mtrans.IDENTITY )
def get_yticks(self):
'Return the y ticks as a list of locations'
@@ -1700,7 +1723,7 @@
def get_yticklabels(self):
'Get the ytick labels as a list of Text instances'
- return mpl.cbook.silent_list('Text yticklabel', self.yaxis.get_ticklabels())
+ return cbook.silent_list('Text yticklabel', self.yaxis.get_ticklabels())
def set_yticklabels(self, labels, fontdict=None, **kwargs):
"""
@@ -1715,13 +1738,13 @@
ACCEPTS: sequence of strings
"""
return self.yaxis.set_ticklabels(labels, fontdict, **kwargs)
- set_yticklabels.__doc__ = mpl.cbook.dedent(set_yticklabels.__doc__) % mpl.artist.kwdocd
+ set_yticklabels.__doc__ = cbook.dedent(set_yticklabels.__doc__) % martist.kwdocd
def toggle_log_lineary(self):
'toggle between log and linear on the y axis'
funcy = self.transData.get_funcy().get_type()
- if funcy==mpl.transforms.LOG10: self.set_yscale('linear')
- elif funcy==mpl.transforms.IDENTITY: self.set_yscale('log')
+ if funcy==mtrans.LOG10: self.set_yscale('linear')
+ elif funcy==mtrans.IDENTITY: self.set_yscale('log')
def xaxis_date(self, tz=None):
"""Sets up x-axis ticks and labels that treat the x data as dates.
@@ -1730,13 +1753,13 @@
"""
locator = self.xaxis.get_major_locator()
- if not isinstance(locator, mpl.dates.DateLocator):
- locator = mpl.dates.AutoDateLocator(tz)
+ if not isinstance(locator, mdates.DateLocator):
+ locator = mdates.AutoDateLocator(tz)
self.xaxis.set_major_locator(locator)
formatter = self.xaxis.get_major_formatter()
- if not isinstance(formatter, mpl.dates.DateFormatter):
- formatter = mpl.dates.AutoDateFormatter(locator)
+ if not isinstance(formatter, mdates.DateFormatter):
+ formatter = mdates.AutoDateFormatter(locator)
self.xaxis.set_major_formatter(formatter)
def yaxis_date(self, tz=None):
@@ -1746,13 +1769,13 @@
"""
locator = self.yaxis.get_major_locator()
- if not isinstance(locator, mpl.dates.DateLocator):
- locator = mpl.dates.AutoDateLocator(tz)
+ if not isinstance(locator, mdates.DateLocator):
+ locator = mdates.AutoDateLocator(tz)
self.yaxis.set_major_locator(locator)
formatter = self.xaxis.get_major_formatter()
- if not isinstance(formatter, mpl.dates.DateFormatter):
- formatter = mpl.dates.AutoDateFormatter(locator)
+ if not isinstance(formatter, mdates.DateFormatter):
+ formatter = mdates.AutoDateFormatter(locator)
self.yaxis.set_major_formatter(formatter)
def format_xdata(self, x):
@@ -1836,7 +1859,7 @@
lw, c = args
else:
raise ValueError('args must be a (linewidth, color) tuple')
- c =mpl.colors.colorConverter.to_rgba(c)
+ c =mcolors.colorConverter.to_rgba(c)
self._cursorProps = lw, c
@@ -1924,7 +1947,7 @@
if len(args)>1:
raise DeprecationWarning(
'New pick API implemented -- see API_CHANGES in the src distribution')
- mpl.artist.Artist.pick(self,args[0])
+ martist.Artist.pick(self,args[0])
def __pick(self, x, y, trans=None, among=None):
"""
@@ -1969,7 +1992,7 @@
verts = a.get_verts()
tverts = a.get_transform().seq_xy_tups(verts)
xt, yt = zip(*tverts)
- elif isinstance(a, mpl.lines.Line2D):
+ elif isinstance(a, mlines.Line2D):
xdata = a.get_xdata(orig=False)
ydata = a.get_ydata(orig=False)
xt, yt = a.get_transform().numerix_x_y(xdata, ydata)
@@ -1979,7 +2002,7 @@
artists = self.lines + self.patches + self.texts
if callable(among):
artists = filter(test, artists)
- elif mpl.cbook.iterable(among):
+ elif iterable(among):
amongd = dict([(k,1) for k in among])
artists = [a for a in artists if a in amongd]
elif among is None:
@@ -2018,7 +2041,7 @@
if fontdict is not None: self.title.update(fontdict)
self.title.update(kwargs)
return self.title
- set_title.__doc__ = mpl.cbook.dedent(set_title.__doc__) % mpl.artist.kwdocd
+ set_title.__doc__ = cbook.dedent(set_title.__doc__) % martist.kwdocd
def set_xlabel(self, xlabel, fontdict=None, **kwargs):
"""
@@ -2037,7 +2060,7 @@
if fontdict is not None: label.update(fontdict)
label.update(kwargs)
return label
- set_xlabel.__doc__ = mpl.cbook.dedent(set_xlabel.__doc__) % mpl.artist.kwdocd
+ set_xlabel.__doc__ = cbook.dedent(set_xlabel.__doc__) % martist.kwdocd
def set_ylabel(self, ylabel, fontdict=None, **kwargs):
"""
@@ -2057,7 +2080,7 @@
if fontdict is not None: label.update(fontdict)
label.update(kwargs)
return label
- set_ylabel.__doc__ = mpl.cbook.dedent(set_ylabel.__doc__) % mpl.artist.kwdocd
+ set_ylabel.__doc__ = cbook.dedent(set_ylabel.__doc__) % martist.kwdocd
def text(self, x, y, s, fontdict=None,
withdash=False, **kwargs):
@@ -2114,11 +2137,11 @@
# the withdash kwarg and simply delegate whether there's
# a dash to TextWithDash and dashlength.
if withdash:
- t = mpl.text.TextWithDash(
+ t = mtext.TextWithDash(
x=x, y=y, text=s,
)
else:
- t = mpl.text.Text(
+ t = mtext.Text(
x=x, y=y, text=s,
)
self._set_artist_props(t)
@@ -2132,7 +2155,7 @@
#if t.get_clip_on(): t.set_clip_box(self.bbox)
if kwargs.has_key('clip_on'): t.set_clip_box(self.bbox)
return t
- text.__doc__ = mpl.cbook.dedent(text.__doc__) % mpl.artist.kwdocd
+ text.__doc__ = cbook.dedent(text.__doc__) % martist.kwdocd
def annotate(self, *args, **kwargs):
"""
@@ -2145,13 +2168,13 @@
%(Annotation)s
"""
- a = mpl.text.Annotation(*args, **kwargs)
- a.set_transform(mpl.transforms.identity_transform())
+ a = mtext.Annotation(*args, **kwargs)
+ a.set_transform(mtrans.identity_transform())
self._set_artist_props(a)
if kwargs.has_key('clip_on'): a.set_clip_box(self.bbox)
self.texts.append(a)
return a
- annotate.__doc__ = mpl.cbook.dedent(annotate.__doc__) % mpl.artist.kwdocd
+ annotate.__doc__ = cbook.dedent(annotate.__doc__) % martist.kwdocd
#### Lines and spans
@@ -2185,11 +2208,11 @@
%(Line2D)s
"""
- trans = mpl.transforms.blend_xy_sep_transform( self.transAxes, self.transData)
+ trans = mtrans.blend_xy_sep_transform( self.transAxes, self.transData)
l, = self.plot([xmin,xmax], [y,y], transform=trans, scalex=False, **kwargs)
return l
- axhline.__doc__ = mpl.cbook.dedent(axhline.__doc__) % mpl.artist.kwdocd
+ axhline.__doc__ = cbook.dedent(axhline.__doc__) % martist.kwdocd
def axvline(self, x=0, ymin=0, ymax=1, **kwargs):
"""
@@ -2221,11 +2244,11 @@
%(Line2D)s
"""
- trans = mpl.transforms.blend_xy_sep_transform( self.transData, self.transAxes )
+ trans = mtrans.blend_xy_sep_transform( self.transData, self.transAxes )
l, = self.plot([x,x], [ymin,ymax] , transform=trans, scaley=False, **kwargs)
return l
- axvline.__doc__ = mpl.cbook.dedent(axvline.__doc__) % mpl.artist.kwdocd
+ axvline.__doc__ = cbook.dedent(axvline.__doc__) % martist.kwdocd
def axhspan(self, ymin, ymax, xmin=0, xmax=1, **kwargs):
"""
@@ -2260,13 +2283,13 @@
%(Polygon)s
"""
# convert y axis units
- trans = mpl.transforms.blend_xy_sep_transform( self.transAxes, self.transData)
+ trans = mtrans.blend_xy_sep_transform( self.transAxes, self.transData)
verts = (xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, ymin)
- p = mpl.patches.Polygon(verts, **kwargs)
+ p = mpatches.Polygon(verts, **kwargs)
p.set_transform(trans)
self.add_patch(p)
return p
- axhspan.__doc__ = mpl.cbook.dedent(axhspan.__doc__) % mpl.artist.kwdocd
+ axhspan.__doc__ = cbook.dedent(axhspan.__doc__) % martist.kwdocd
def axvspan(self, xmin, xmax, ymin=0, ymax=1, **kwargs):
"""
@@ -2300,13 +2323,13 @@
%(Polygon)s
"""
# convert x axis units
- trans = mpl.transforms.blend_xy_sep_transform(self.transData, self.transAxes)
+ trans = mtrans.blend_xy_sep_transform(self.transData, self.transAxes)
verts = [(xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, ymin)]
- p = mpl.patches.Polygon(verts, **kwargs)
+ p = mpatches.Polygon(verts, **kwargs)
p.set_transform(trans)
self.add_patch(p)
return p
- axvspan.__doc__ = mpl.cbook.dedent(axvspan.__doc__) % mpl.artist.kwdocd
+ axvspan.__doc__ = cbook.dedent(axvspan.__doc__) % martist.kwdocd
def hlines(self, y, xmin, xmax, colors='k', linestyle='solid',
@@ -2331,10 +2354,16 @@
raise DeprecationWarning(
'hlines now uses a collections.LineCollection and not a list of Line2D to draw; see API_CHANGES')
- if not mpl.cbook.iterable(y): y = [y]
- if not mpl.cbook.iterable(xmin): xmin = [xmin]
- if not mpl.cbook.iterable(xmax): xmax = [xmax]
+ if not iterable(y): y = [y]
+ if not iterable(xmin): xmin = [xmin]
+ if not iterable(xmax): xmax = [xmax]
y = npy.asarray(y)
+
+ if len(xmin)==1:
+ xmin = xmin*ones(y.shape, y.dtype)
+ if len(ymax)==1:
+ xmax = xmax*ones(y.shape, y.dtype)
+
xmin = npy.asarray(xmin)
xmax = npy.asarray(xmax)
@@ -2349,7 +2378,7 @@
verts = [ ((thisxmin, thisy), (thisxmax, thisy))
for thisxmin, thisxmax, thisy in zip(xmin, xmax, y)]
- coll = mpl.collections.LineCollection(verts, colors=colors,
+ coll = mcoll.LineCollection(verts, colors=colors,
linestyle=linestyle, label=label)
self.add_collection(coll)
@@ -2369,7 +2398,7 @@
return coll
- hlines.__doc__ = mpl.cbook.dedent(hlines.__doc__)
+ hlines.__doc__ = cbook.dedent(hlines.__doc__)
def vlines(self, x, ymin, ymax, colors='k', linestyle='solid',
label='', **kwargs):
@@ -2400,9 +2429,9 @@
self._process_unit_info(xdata=x, ydata=ymin, kwargs=kwargs)
- if not mpl.cbook.iterable(x): x = [x]
- if not mpl.cbook.iterable(ymin): ymin = [ymin]
- if not mpl.cbook.iterable(ymax): ymax = [ymax]
+ if not iterable(x): x = [x]
+ if not iterable(ymin): ymin = [ymin]
+ if not iterable(ymax): ymax = [ymax]
x = npy.asarray(x)
ymin = npy.asarray(ymin)
ymax = npy.asarray(ymax)
@@ -2424,7 +2453,7 @@
verts = [ ((thisx, thisymin), (thisx, thisymax))
for thisx, (thisymin, thisymax) in zip(x,Y)]
#print 'creating line collection'
- coll = mpl.collections.LineCollection(verts, colors=colors,
+ coll = mcoll.LineCollection(verts, colors=colors,
linestyle=linestyle, label=label)
self.add_collection(coll)
coll.update(kwargs)
@@ -2432,7 +2461,7 @@
minx = x.min()
maxx = x.max()
miny = min(ymin.min(), ymax.min())
- maxy = max(ymax.max(), ymax.max())
+ maxy = max(ymin.max(), ymax.max())
minx, maxx = self.convert_xunits((minx, maxx))
miny, maxy = self.convert_yunits((miny, maxy))
corners = (minx, miny), (maxx, maxy)
@@ -2440,7 +2469,7 @@
self.autoscale_view()
return coll
- vlines.__doc__ = mpl.cbook.dedent(vlines.__doc__) % mpl.artist.kwdocd
+ vlines.__doc__ = cbook.dedent(vlines.__doc__) % martist.kwdocd
#### Basic plotting
def plot(self, *args, **kwargs):
@@ -2555,7 +2584,7 @@
self.autoscale_view(scalex=scalex, scaley=scaley)
return lines
- plot.__doc__ = mpl.cbook.dedent(plot.__doc__) % mpl.artist.kwdocd
+ plot.__doc__ = cbook.dedent(plot.__doc__) % martist.kwdocd
def plot_date(self, x, y, fmt='bo', tz=None, xdate=True, ydate=False,
**kwargs):
@@ -2604,7 +2633,7 @@
self.autoscale_view()
return ret
- plot_date.__doc__ = mpl.cbook.dedent(plot_date.__doc__) % mpl.artist.kwdocd
+ plot_date.__doc__ = cbook.dedent(plot_date.__doc__) % martist.kwdocd
def loglog(self, *args, **kwargs):
@@ -2652,7 +2681,7 @@
self._hold = b # restore the hold
return l
- loglog.__doc__ = mpl.cbook.dedent(loglog.__doc__) % mpl.artist.kwdocd
+ loglog.__doc__ = cbook.dedent(loglog.__doc__) % martist.kwdocd
def semilogx(self, *args, **kwargs):
"""
@@ -2685,7 +2714,7 @@
l = self.plot(*args, **kwargs)
self._hold = b # restore the hold
return l
- semilogx.__doc__ = mpl.cbook.dedent(semilogx.__doc__) % mpl.artist.kwdocd
+ semilogx.__doc__ = cbook.dedent(semilogx.__doc__) % martist.kwdocd
def semilogy(self, *args, **kwargs):
"""
@@ -2719,7 +2748,7 @@
self._hold = b # restore the hold
return l
- semilogy.__doc__ = mpl.cbook.dedent(semilogy.__doc__) % mpl.artist.kwdocd
+ semilogy.__doc__ = cbook.dedent(semilogy.__doc__) % martist.kwdocd
def acorr(self, x, **kwargs):
"""
@@ -2754,9 +2783,9 @@
See the respective function for documentation on valid kwargs
"""
return self.xcorr(x, x, **kwargs)
- acorr.__doc__ = mpl.cbook.dedent(acorr.__doc__) % mpl.artist.kwdocd
+ acorr.__doc__ = cbook.dedent(acorr.__doc__) % martist.kwdocd
- def xcorr(self, x, y, normed=False, detrend=mpl.mlab.detrend_none, usevlines=False,
+ def xcorr(self, x, y, normed=False, detrend=mlab.detrend_none, usevlines=False,
maxlags=None, **kwargs):
"""
XCORR(x, y, normed=False, detrend=mlab.detrend_none, usevlines=False, **kwargs):
@@ -2821,7 +2850,7 @@
a, = self.plot(lags, c, **kwargs)
b = None
return lags, c, a, b
- xcorr.__doc__ = mpl.cbook.dedent(xcorr.__doc__) % mpl.artist.kwdocd
+ xcorr.__doc__ = cbook.dedent(xcorr.__doc__) % martist.kwdocd
def legend(self, *args, **kwargs):
"""
@@ -2893,9 +2922,9 @@
handles = self.lines[:]
handles.extend(self.patches)
handles.extend([c for c in self.collections
- if isinstance(c, mpl.collections.LineCollection)])
+ if isinstance(c, mcoll.LineCollection)])
handles.extend([c for c in self.collections
- if isinstance(c, mpl.collections.RegularPolyCollection)])
+ if isinstance(c, mcoll.RegularPolyCollection)])
return handles
if len(args)==0:
@@ -2916,7 +2945,7 @@
handles = [h for h, label in zip(get_handles(), labels)]
elif len(args)==2:
- if mpl.cbook.is_string_like(args[1]) or isinstance(args[1], int):
+ if is_string_like(args[1]) or isinstance(args[1], int):
# LABELS, LOC
labels, loc = args
handles = [h for h, label in zip(get_handles(), labels)]
@@ -2933,8 +2962,8 @@
raise TypeError('Invalid arguments to legend')
- handles = mpl.cbook.flatten(handles)
- self.legend_ = mpl.legend.Legend(self, handles, labels, **kwargs)
+ handles = cbook.flatten(handles)
+ self.legend_ = mlegend.Legend(self, handles, labels, **kwargs)
return self.legend_
@@ -3011,7 +3040,7 @@
if not self._hold: self.cla()
def make_iterable(x):
- if not mpl.cbook.iterable(x):
+ if not iterable(x):
return [x]
else:
return x
@@ -3071,24 +3100,24 @@
# if color looks like a color string, an RGB tuple or a
# scalar, then repeat it by nbars
- if (mpl.cbook.is_string_like(color) or
- (mpl.cbook.iterable(color) and len(color)==3 and nbars!=3) or
- not mpl.cbook.iterable(color)):
+ if (is_string_like(color) or
+ (iterable(color) and len(color)==3 and nbars!=3) or
+ not iterable(color)):
color = [color]*nbars
# if edgecolor looks like a color string, an RGB tuple or a
# scalar, then repeat it by nbars
- if (mpl.cbook.is_string_like(edgecolor) or
- (mpl.cbook.iterable(edgecolor) and len(edgecolor)==3 and nbars!=3) or
- not mpl.cbook.iterable(edgecolor)):
+ if (is_string_like(edgecolor) or
+ (iterable(edgecolor) and len(edgecolor)==3 and nbars!=3) or
+ not iterable(edgecolor)):
edgecolor = [edgecolor]*nbars
if yerr is not None:
- if not mpl.cbook.iterable(yerr):
+ if not iterable(yerr):
yerr = [yerr]*nbars
if xerr is not None:
- if not mpl.cbook.iterable(xerr):
+ if not iterable(xerr):
xerr = [xerr]*nbars
assert len(left)==nbars, "argument 'left' must be %d or scalar" % nbars
@@ -3139,7 +3168,7 @@
if w<0:
l += w
w = abs(w)
- r = mpl.patches.Rectangle(
+ r = mpatches.Rectangle(
xy=(l, b), width=w, height=h,
facecolor=c,
edgecolor=e,
@@ -3184,7 +3213,7 @@
self.dataLim.intervaly().set_bounds(ymin, ymax)
self.autoscale_view()
return patches
- bar.__doc__ = mpl.cbook.dedent(bar.__doc__) % mpl.artist.kwdocd
+ bar.__doc__ = cbook.dedent(bar.__doc__) % martist.kwdocd
def barh(self, bottom, width, height=0.8, left=None, **kwargs):
"""
@@ -3246,7 +3275,7 @@
orientation='horizontal', **kwargs)
return patches
- barh.__doc__ = mpl.cbook.dedent(barh.__doc__) % mpl.artist.kwdocd
+ barh.__doc__ = cbook.dedent(barh.__doc__) % martist.kwdocd
def broken_barh(self, xranges, yrange, **kwargs):
"""
@@ -3264,13 +3293,13 @@
facecolors='black', 'red', 'green'
"""
- col = mpl.collections.BrokenBarHCollection(xranges, yrange, **kwargs)
+ col = mcoll.BrokenBarHCollection(xranges, yrange, **kwargs)
self.add_collection(col, autolim=True)
self.autoscale_view()
return col
- broken_barh.__doc__ = mpl.cbook.dedent(broken_barh.__doc__) % mpl.artist.kwdocd
+ broken_barh.__doc__ = cbook.dedent(broken_barh.__doc__) % martist.kwdocd
def stem(self, x, y, linefmt='b-', markerfmt='bo', basefmt='r-'):
"""
@@ -3350,7 +3379,7 @@
Return value:
If autopct is None, return a list of (patches, texts), where patches
- is a sequence of mpl.patches.Wedge instances and texts is a
+ is a sequence of mpatches.Wedge instances and texts is a
list of the label Text instnaces
If autopct is not None, return (patches, texts, autotexts), where
@@ -3385,7 +3414,7 @@
x += expl*math.cos(thetam)
y += expl*math.sin(thetam)
- w = mpl.patches.Wedge((x,y), radius, 360.*theta1, 360.*theta2,
+ w = mpatches.Wedge((x,y), radius, 360.*theta1, 360.*theta2,
facecolor=colors[i%len(colors)])
slices.append(w)
self.add_patch(w)
@@ -3395,7 +3424,7 @@
# make sure to add a shadow after the call to
# add_patch so the figure and transform props will be
# set
- shad = mpl.patches.Shadow(w, -0.02, -0.02,
+ shad = mpatches.Shadow(w, -0.02, -0.02,
#props={'facecolor':w.get_facecolor()}
)
shad.set_zorder(0.9*w.get_zorder())
@@ -3415,7 +3444,7 @@
if autopct is not None:
xt = x + pctdistance*radius*math.cos(thetam)
yt = y + pctdistance*radius*math.sin(thetam)
- if mpl.cbook.is_string_like(autopct):
+ if is_string_like(autopct):
s = autopct%(100.*frac)
elif callable(autopct):
s = autopct(100.*frac)
@@ -3501,18 +3530,18 @@
if not self._hold: self.cla()
# make sure all the args are iterable arrays
- if not mpl.cbook.iterable(x): x = npy.asarray([x])
+ if not iterable(x): x = npy.asarray([x])
else: x = npy.asarray(x)
- if not mpl.cbook.iterable(y): y = npy.asarray([y])
+ if not iterable(y): y = npy.asarray([y])
else: y = npy.asarray(y)
if xerr is not None:
- if not mpl.cbook.iterable(xerr): xerr = npy.asarray([xerr])
+ if not iterable(xerr): xerr = npy.asarray([xerr])
else: xerr = npy.asarray(xerr)
if yerr is not None:
- if not mpl.cbook.iterable(yerr): yerr = npy.asarray([yerr])
+ if not iterable(yerr): yerr = npy.asarray([yerr])
else: yerr = npy.asarray(yerr)
l0 = None
@@ -3581,7 +3610,7 @@
self.autoscale_view()
return (l0, caplines, barcols)
- errorbar.__doc__ = mpl.cbook.dedent(errorbar.__doc__) % mpl.artist.kwdocd
+ errorbar.__doc__ = cbook.dedent(errorbar.__doc__) % martist.kwdocd
def boxplot(self, x, notch=0, sym='b+', vert=1, whis=1.5,
positions=None, widths=None):
@@ -3663,7 +3692,7 @@
d = npy.ravel(x[i])
row = len(d)
# get median and quartiles
- q1, med, q3 = mpl.mlab.prctile(d,[25,50,75])
+ q1, med, q3 = mlab.prctile(d,[25,50,75])
# get high extreme
iq = q3 - q1
hi_val = q3 + whis*iq
@@ -3870,16 +3899,16 @@
# The inherent ambiguity is resolved in favor of color
# mapping, not interpretation as rgb or rgba.
- if not mpl.cbook.is_string_like(c):
+ if not is_string_like(c):
sh = npy.shape(c)
if len(sh) == 1 and sh[0] == len(x):
colors = None # use cmap, norm after collection is created
else:
- colors = mpl.colors.colorConverter.to_rgba_list(c, alpha)
+ colors = mcolors.colorConverter.to_rgba_list(c, alpha)
else:
- colors = mpl.colors.colorConverter.to_rgba_list(c, alpha)
+ colors = mcolors.colorConverter.to_rgba_list(c, alpha)
- if not mpl.cbook.iterable(s):
+ if not iterable(s):
scales = (s,)
else:
scales = s
@@ -3895,14 +3924,14 @@
marker = (verts, 0)
verts = None
- if mpl.cbook.is_string_like(marker):
+ if is_string_like(marker):
# the standard way to define symbols using a string character
sym = syms.get(marker)
if sym is None and verts is None:
raise ValueError('Unknown marker symbol to scatter')
numsides, rotation = syms[marker]
- elif mpl.cbook.iterable(marker):
+ elif iterable(marker):
# accept marker to be:
# (numsides, style, [angle])
# or
@@ -3911,7 +3940,7 @@
if len(marker)<2 or len(marker)>3:
raise ValueError('Cannot create markersymbol from marker')
- if mpl.cbook.is_numlike(marker[0]):
+ if cbook.is_numlike(marker[0]):
# (numsides, style, [angle])
if len(marker)==2:
@@ -3931,7 +3960,7 @@
if sym is not None:
if not starlike:
- collection = mpl.collections.RegularPolyCollection(
+ collection = mcoll.RegularPolyCollection(
self.figure.dpi,
numsides, rotation, scales,
facecolors = colors,
@@ -3941,7 +3970,7 @@
transOffset = self.transData,
)
else:
- collection = mpl.collections.StarPolygonCollection(
+ collection = mcoll.StarPolygonCollection(
self.figure.dpi,
numsides, rotation, scales,
facecolors = colors,
@@ -3962,7 +3991,7 @@
else:
# todo -- make this nx friendly
verts = [verts*s for s in scales]
- collection = mpl.collections.PolyCollection(
+ collection = mcoll.PolyCollection(
verts,
facecolors = colors,
edgecolors = edgecolors,
@@ -3970,13 +3999,13 @@
offsets = zip(x,y),
transOffset = self.transData,
)
- collection.set_transform(mpl.transforms.identity_transform())
+ collection.set_transform(mtrans.identity_transform())
collection.set_alpha(alpha)
collection.update(kwargs)
if colors is None:
- if norm is not None: assert(isinstance(norm, mpl.colors.Normalize))
- if cmap is not None: assert(isinstance(cmap, mpl.colors.Colormap))
+ if norm is not None: assert(isinstance(norm, mcolors.Normalize))
+ if cmap is not None: assert(isinstance(cmap, mcolors.Colormap))
collection.set_array(npy.asarray(c))
collection.set_cmap(cmap)
collection.set_norm(norm)
@@ -4010,7 +4039,7 @@
self.add_collection(collection)
return collection
- scatter.__doc__ = mpl.cbook.dedent(scatter.__doc__) % mpl.artist.kwdocd
+ scatter.__doc__ = cbook.dedent(scatter.__doc__) % martist.kwdocd
def scatter_classic(self, x, y, s=None, c='b'):
"""
@@ -4047,35 +4076,35 @@
Optional kwargs control the arrow properties:
%(Arrow)s
"""
- a = mpl.patches.FancyArrow(x, y, dx, dy, **kwargs)
+ a = mpatches.FancyArrow(x, y, dx, dy, **kwargs)
self.add_artist(a)
return a
- arrow.__doc__ = mpl.cbook.dedent(arrow.__doc__) % mpl.artist.kwdocd
+ arrow.__doc__ = cbook.dedent(arrow.__doc__) % martist.kwdocd
def quiverkey(self, *args, **kw):
- qk = mpl.quiver.QuiverKey(*args, **kw)
+ qk = mquiver.QuiverKey(*args, **kw)
self.add_artist(qk)
return qk
- quiverkey.__doc__ = mpl.quiver.QuiverKey.quiverkey_doc
+ quiverkey.__doc__ = mquiver.QuiverKey.quiverkey_doc
def quiver2(self, *args, **kw):
- q = mpl.quiver.Quiver(self, *args, **kw)
+ q = mquiver.Quiver(self, *args, **kw)
self.add_collection(q)
self.update_datalim_numerix(q.X, q.Y)
self.autoscale_view()
return q
- quiver2.__doc__ = mpl.quiver.Quiver.quiver_doc
+ quiver2.__doc__ = mquiver.Quiver.quiver_doc
def quiver(self, *args, **kw):
- if (len(args) == 3 or len(args) == 5) and not mpl.cbook.iterable(args[-1]):
+ if (len(args) == 3 or len(args) == 5) and not iterable(args[-1]):
return self.quiver_classic(*args, **kw)
c = kw.get('color', None)
if c is not None:
- if not mpl.colors.is_color_like(c):
+ if not mcolors.is_color_like(c):
assert npy.shape(npy.asarray(c)) == npy.shape(npy.asarray(args[-1]))
return self.quiver_classic(*args, **kw)
return self.quiver2(*args, **kw)
- quiver.__doc__ = mpl.quiver.Quiver.quiver_doc
+ quiver.__doc__ = mquiver.Quiver.quiver_doc
def quiver_classic(self, U, V, *args, **kwargs ):
"""
@@ -4119,12 +4148,12 @@
# ( U, V )
U = npy.asarray(U)
V = npy.asarray(V)
- X,Y = mpl.mlab.meshgrid( npy.arange(U.shape[1]), npy.arange(U.shape[0]) )
+ X,Y = mlab.meshgrid( npy.arange(U.shape[1]), npy.arange(U.shape[0]) )
elif len(args)==1:
# ( U, V, S )
U = npy.asarray(U)
V = npy.asarray(V)
- X,Y = mpl.mlab.meshgrid( npy.arange(U.shape[1]), npy.arange(U.shape[0]) )
+ X,Y = mlab.meshgrid( npy.arange(U.shape[1]), npy.arange(U.shape[0]) )
S = float(args[0])
do_scale = ( S != 0.0 )
elif len(args)==2:
@@ -4186,10 +4215,10 @@
C = clr
I = U.shape[0]
- arrows = [mpl.patches.FancyArrow(X[i],Y[i],U[i],V[i],0.1*S ).get_verts()
+ arrows = [mpatches.FancyArrow(X[i],Y[i],U[i],V[i],0.1*S ).get_verts()
for i in xrange(I)]
- collection = mpl.collections.PolyCollection(
+ collection = mcoll.PolyCollection(
arrows,
edgecolors = 'None',
antialiaseds = (1,),
@@ -4255,7 +4284,7 @@
patches.append( poly )
self.autoscale_view()
return patches
- fill.__doc__ = mpl.cbook.dedent(fill.__doc__) % mpl.artist.kwdocd
+ fill.__doc__ = cbook.dedent(fill.__doc__) % martist.kwdocd
#### plotting z(x,y): imshow, pcolor and relatives, contour
@@ -4299,7 +4328,7 @@
The value for each component of MxNx3 and MxNx4 float arrays should be
in the range 0.0 to 1.0; MxN float arrays may be normalised.
- A mpl.image.AxesImage instance is returned
+ A image.AxesImage instance is returned
The following kwargs are allowed:
@@ -4320,7 +4349,7 @@
image.interpolation. See also th the filternorm and
filterrad parameters
- * norm is a mpl.colors.Normalize instance; default is
+ * norm is a mcolors.Normalize instance; default is
normalization(). This scales luminance -> 0-1 (only used for an
MxN float array).
@@ -4354,16 +4383,16 @@
parameter, ie when interpolation is one of: 'sinc',
'lanczos' or 'blackman'
- Additional kwargs are mpl.artist properties
+ Additional kwargs are martist properties
"""
if not self._hold: self.cla()
- if norm is not None: assert(isinstance(norm, mpl.colors.Normalize))
- if cmap is not None: assert(isinstance(cmap, mpl.colors.Colormap))
+ if norm is not None: assert(isinstance(norm, mcolors.Normalize))
+ if cmap is not None: assert(isinstance(cmap, mcolors.Colormap))
if aspect is None: aspect = rcParams['image.aspect']
self.set_aspect(aspect)
- im = mpl.image.AxesImage(self, cmap, norm, interpolation, origin, extent,
+ im = mimage.AxesImage(self, cmap, norm, interpolation, origin, extent,
filternorm=filternorm,
filterrad=filterrad, **kwargs)
@@ -4423,9 +4452,9 @@
Optional keyword args are shown with their defaults below (you must
use kwargs for these):
- * cmap = mpl.cm.jet : a cm Colormap instance from mpl.cm
+ * cmap = cm.jet : a cm Colormap instance from cm
- * norm = Normalize() : mpl.colors.Normalize instance
+ * norm = Normalize() : mcolors.Normalize instance
is used to scale luminance data to 0,1.
* vmin=None and vmax=None : vmin and vmax are used in conjunction
@@ -4438,7 +4467,7 @@
* alpha=1.0 : the alpha blending value
- Return value is a mpl.collections.PatchCollection
+ Return value is a mcoll.PatchCollection
object
Grid Orientation
@@ -4497,7 +4526,7 @@
if len(args)==1:
C = args[0]
numRows, numCols = C.shape
- X, Y = mpl.mlab.meshgrid(npy.arange(numCols+1), npy.arange(numRows+1) )
+ X, Y = mlab.meshgrid(npy.arange(numCols+1), npy.arange(numRows+1) )
elif len(args)==3:
X, Y, C = args
numRows, numCols = C.shape
@@ -4553,7 +4582,7 @@
else:
edgecolors = 'None'
- collection = mpl.collections.PolyCollection(
+ collection = mcoll.PolyCollection(
verts,
edgecolors = edgecolors,
antialiaseds = (0,),
@@ -4563,8 +4592,8 @@
collection.set_alpha(alpha)
collection.set_array(C)
- if norm is not None: assert(isinstance(norm, mpl.colors.Normalize))
- if cmap is not None: assert(isinstance(cmap, mpl.colors.Colormap))
+ if norm is not None: assert(isinstance(norm, mcolors.Normalize))
+ if cmap is not None: assert(isinstance(cmap, mcolors.Colormap))
collection.set_cmap(cmap)
collection.set_norm(norm)
if vmin is not None or vmax is not None:
@@ -4585,7 +4614,7 @@
self.autoscale_view()
self.add_collection(collection)
return collection
- pcolor.__doc__ = mpl.cbook.dedent(pcolor.__doc__) % mpl.artist.kwdocd
+ pcolor.__doc__ = cbook.dedent(pcolor.__doc__) % martist.kwdocd
def pcolormesh(self, *args, **kwargs):
"""
@@ -4646,7 +4675,7 @@
if len(args)==1:
C = args[0]
numRows, numCols = C.shape
- X, Y = mpl.mlab.meshgrid(npy.arange(numCols+1), npy.arange(numRows+1) )
+ X, Y = mlab.meshgrid(npy.arange(numCols+1), npy.arange(numRows+1) )
elif len(args)==3:
X, Y, C = args
numRows, numCols = C.shape
@@ -4674,12 +4703,12 @@
else:
showedges = 0
- collection = mpl.collections.QuadMesh(
+ collection = mcoll.QuadMesh(
Nx - 1, Ny - 1, coords, showedges, **kwargs)
collection.set_alpha(alpha)
collection.set_array(C)
- if norm is not None: assert(isinstance(norm, mpl.colors.Normalize))
- if cmap is not None: assert(isinstance(cmap, mpl.colors.Colormap))
+ if norm is not None: assert(isinstance(norm, mcolors.Normalize))
+ if cmap is not None: assert(isinstance(cmap, mcolors.Colormap))
collection.set_cmap(cmap)
collection.set_norm(norm)
if vmin is not None or vmax is not None:
@@ -4699,21 +4728,21 @@
self.autoscale_view()
self.add_collection(collection)
return collection
- pcolormesh.__doc__ = mpl.cbook.dedent(pcolormesh.__doc__) % mpl.artist.kwdocd
+ pcolormesh.__doc__ = cbook.dedent(pcolormesh.__doc__) % martist.kwdocd
def contour(self, *args, **kwargs):
kwargs['filled'] = False
- return mpl.contour.ContourSet(self, *args, **kwargs)
- contour.__doc__ = mpl.contour.ContourSet.contour_doc
+ return mcontour.ContourSet(self, *args, **kwargs)
+ contour.__doc__ = mcontour.ContourSet.contour_doc
def contourf(self, *args, **kwargs):
kwargs['filled'] = True
- return mpl.contour.ContourSet(self, *args, **kwargs)
- contourf.__doc__ = mpl.contour.ContourSet.contour_doc
+ return mcontour.ContourSet(self, *args, **kwargs)
+ contourf.__doc__ = mcontour.ContourSet.contour_doc
def clabel(self, CS, *args, **kwargs):
return CS.clabel(*args, **kwargs)
- clabel.__doc__ = mpl.contour.ContourSet.clabel.__doc__
+ ...
[truncated message content] |