|
8 | 8 |
|
9 | 9 | import numpy as npy |
10 | 10 | import matplotlib.numerix.npyma as ma |
11 | | - |
12 | | -from cbook import is_string_like, enumerate, strip_math, Stack, CallbackRegistry |
13 | | -from colors import colorConverter |
14 | | -from numerix import array, sqrt, pi, log, asarray, ones, zeros, Float, Float32 |
15 | | -from numerix import arange, compress, take, isnan, any |
16 | | -from patches import Rectangle |
17 | | -from transforms import lbwh_to_bbox, identity_transform |
18 | | -import widgets |
| 11 | +import matplotlib.cbook as cbook |
| 12 | +import matplotlib.colors as colors |
| 13 | +import matplotlib.transforms as transforms |
| 14 | +import matplotlib.widgets as widgets |
19 | 15 |
|
20 | 16 | class RendererBase: |
21 | 17 | """An abstract base class to handle drawing/rendering operations |
@@ -141,7 +137,7 @@ def draw_line_collection(self, segments, transform, clipbox, |
141 | 137 | """ |
142 | 138 |
|
143 | 139 | newstyle = getattr(self, 'draw_markers', None) is not None |
144 | | - identity = identity_transform() |
| 140 | + identity = transforms.identity_transform() |
145 | 141 | gc = self.new_gc() |
146 | 142 | if clipbox is not None: |
147 | 143 | gc.set_clip_rectangle(clipbox.get_bounds()) |
@@ -204,18 +200,18 @@ def draw_quad_mesh(self, meshWidth, meshHeight, colors, |
204 | 200 | See documentation in QuadMesh class in collections.py for details |
205 | 201 | """ |
206 | 202 | # print "draw_quad_mesh not found, using function in backend_bases" |
207 | | - verts = zeros(((meshWidth * meshHeight), 4, 2), Float32) |
208 | | - indices = arange((meshWidth + 1) * (meshHeight + 1)) |
209 | | - indices = compress((indices + 1) % (meshWidth + 1), indices) |
| 203 | + verts = npy.zeros(((meshWidth * meshHeight), 4, 2), npy.float32) |
| 204 | + indices = npy.arange((meshWidth + 1) * (meshHeight + 1)) |
| 205 | + indices = npy.compress((indices + 1) % (meshWidth + 1), indices) |
210 | 206 | indices = indices[:(meshWidth * meshHeight)] |
211 | | - verts[:, 0, 0] = take(xCoords, indices) |
212 | | - verts[:, 0, 1] = take(yCoords, indices) |
213 | | - verts[:, 1, 0] = take(xCoords, (indices + 1)) |
214 | | - verts[:, 1, 1] = take(yCoords, (indices + 1)) |
215 | | - verts[:, 2, 0] = take(xCoords, (indices + meshWidth + 2)) |
216 | | - verts[:, 2, 1] = take(yCoords, (indices + meshWidth + 2)) |
217 | | - verts[:, 3, 0] = take(xCoords, (indices + meshWidth + 1)) |
218 | | - verts[:, 3, 1] = take(yCoords, (indices + meshWidth + 1)) |
| 207 | + verts[:, 0, 0] = npy.take(xCoords, indices) |
| 208 | + verts[:, 0, 1] = npy.take(yCoords, indices) |
| 209 | + verts[:, 1, 0] = npy.take(xCoords, (indices + 1)) |
| 210 | + verts[:, 1, 1] = npy.take(yCoords, (indices + 1)) |
| 211 | + verts[:, 2, 0] = npy.take(xCoords, (indices + meshWidth + 2)) |
| 212 | + verts[:, 2, 1] = npy.take(yCoords, (indices + meshWidth + 2)) |
| 213 | + verts[:, 3, 0] = npy.take(xCoords, (indices + meshWidth + 1)) |
| 214 | + verts[:, 3, 1] = npy.take(yCoords, (indices + meshWidth + 1)) |
219 | 215 | if (showedges): |
220 | 216 | edgecolors = colors |
221 | 217 | else: |
@@ -262,7 +258,7 @@ def draw_poly_collection( |
262 | 258 |
|
263 | 259 | for i in xrange(N): |
264 | 260 | polyverts = ma.filled(verts[i % Nverts], npy.nan) |
265 | | - if any(isnan(polyverts)): |
| 261 | + if npy.any(npy.isnan(polyverts)): |
266 | 262 | continue |
267 | 263 | linewidth = linewidths[i % Nlw] |
268 | 264 | rf,gf,bf,af = facecolors[i % Nface] |
@@ -337,8 +333,8 @@ def draw_regpoly_collection( |
337 | 333 | gc.set_clip_rectangle(clipbox.get_bounds()) |
338 | 334 |
|
339 | 335 | xverts, yverts = zip(*verts) |
340 | | - xverts = asarray(xverts) |
341 | | - yverts = asarray(yverts) |
| 336 | + xverts = npy.asarray(xverts) |
| 337 | + yverts = npy.asarray(yverts) |
342 | 338 |
|
343 | 339 | Nface = len(facecolors) |
344 | 340 | Nedge = len(edgecolors) |
@@ -423,7 +419,7 @@ def get_text_extent(self, text): # is not used, can be removed? |
423 | 419 | """ |
424 | 420 | Get the text extent in window coords |
425 | 421 | """ |
426 | | - return lbwh_to_bbox(0,0,1,1) # your values here |
| 422 | + return transforms.lbwh_to_bbox(0,0,1,1) # your values here |
427 | 423 |
|
428 | 424 | def get_text_width_height(self, s, prop, ismath): |
429 | 425 | """ |
@@ -452,7 +448,7 @@ def points_to_pixels(self, points): |
452 | 448 | return points |
453 | 449 |
|
454 | 450 | def strip_math(self, s): |
455 | | - return strip_math(s) |
| 451 | + return cbook.strip_math(s) |
456 | 452 |
|
457 | 453 |
|
458 | 454 | class GraphicsContextBase: |
@@ -618,7 +614,7 @@ def set_foreground(self, fg, isRGB=False): |
618 | 614 | if isRGB: |
619 | 615 | self._rgb = fg |
620 | 616 | else: |
621 | | - self._rgb = colorConverter.to_rgb(fg) |
| 617 | + self._rgb = colors.colorConverter.to_rgb(fg) |
622 | 618 |
|
623 | 619 | def set_graylevel(self, frac): |
624 | 620 | """ |
@@ -870,7 +866,7 @@ def __init__(self, figure): |
870 | 866 | figure.set_canvas(self) |
871 | 867 | self.figure = figure |
872 | 868 | # a dictionary from event name to a dictionary that maps cid->func |
873 | | - self.callbacks = CallbackRegistry(self.events) |
| 869 | + self.callbacks = cbook.CallbackRegistry(self.events) |
874 | 870 | self.widgetlock = widgets.LockDraw() |
875 | 871 | self._button = None # the button pressed |
876 | 872 | self._key = None # the key pressed |
@@ -1174,8 +1170,8 @@ def __init__(self, canvas): |
1174 | 1170 | self.canvas = canvas |
1175 | 1171 | canvas.toolbar = self |
1176 | 1172 | # a dict from axes index to a list of view limits |
1177 | | - self._views = Stack() |
1178 | | - self._positions = Stack() # stack of subplot positions |
| 1173 | + self._views = cbook.Stack() |
| 1174 | + self._positions = cbook.Stack() # stack of subplot positions |
1179 | 1175 | self._xypress = None # the location and axis info at the time of the press |
1180 | 1176 | self._idPress = None |
1181 | 1177 | self._idRelease = None |
@@ -1529,15 +1525,15 @@ def release_zoom(self, event): |
1529 | 1525 | a.set_ylim((ymin, ymax)) |
1530 | 1526 | elif self._button_pressed == 3: |
1531 | 1527 | if a.get_xscale()=='log': |
1532 | | - alpha=log(Xmax/Xmin)/log(xmax/xmin) |
| 1528 | + alpha=npy.log(Xmax/Xmin)/npy.log(xmax/xmin) |
1533 | 1529 | x1=pow(Xmin/xmin,alpha)*Xmin |
1534 | 1530 | x2=pow(Xmax/xmin,alpha)*Xmin |
1535 | 1531 | else: |
1536 | 1532 | alpha=(Xmax-Xmin)/(xmax-xmin) |
1537 | 1533 | x1=alpha*(Xmin-xmin)+Xmin |
1538 | 1534 | x2=alpha*(Xmax-xmin)+Xmin |
1539 | 1535 | if a.get_yscale()=='log': |
1540 | | - alpha=log(Ymax/Ymin)/log(ymax/ymin) |
| 1536 | + alpha=npy.log(Ymax/Ymin)/npy.log(ymax/ymin) |
1541 | 1537 | y1=pow(Ymin/ymin,alpha)*Ymin |
1542 | 1538 | y2=pow(Ymax/ymin,alpha)*Ymin |
1543 | 1539 | else: |
|
0 commit comments