Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 043d24f

Browse filesBrowse files
committed
First pass through all of the examples -- not all working yet,
though. (See PASSED_DEMOS). svn path=/branches/transforms/; revision=3937
1 parent 0c9042e commit 043d24f
Copy full SHA for 043d24f

File tree

13 files changed

+167
-178
lines changed
Filter options

13 files changed

+167
-178
lines changed

‎PASSED_DEMOS

Copy file name to clipboardExpand all lines: PASSED_DEMOS
+56-56Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -148,63 +148,63 @@ pcolor_demo.py O
148148
pcolor_log.py O
149149
pcolor_nonuniform.py O
150150
pcolor_small.py O
151-
pick_event_demo2.py
152-
pick_event_demo.py
153-
pie_demo.py
154-
plotfile_demo.py
155-
polar_bar.py
156-
polar_demo.py
157-
polar_legend.py
158-
polar_scatter.py
159-
poly_editor.py
160-
poormans_contour.py
151+
pick_event_demo2.py O
152+
pick_event_demo.py O
153+
pie_demo.py O
154+
plotfile_demo.py O
155+
polar_bar.py O
156+
polar_demo.py O
157+
polar_legend.py O
158+
polar_scatter.py O
159+
poly_editor.py [NEEDS OVERHAUL]
160+
poormans_contour.py O
161161
printing_in_wx.py
162-
print_stdout.py
163-
psd_demo.py
162+
print_stdout.py [BROKEN?]
163+
psd_demo.py O
164164
pstest.py
165165
pylab_with_gtk.py
166-
pythonic_matplotlib.py
167-
quadmesh_demo.py
168-
quiver_demo.py
169-
rc_traits.py
170-
scatter_custom_symbol.py
171-
scatter_demo2.py
172-
scatter_demo.py
173-
scatter_masked.py
174-
scatter_profile.py
175-
scatter_star_poly.py
176-
set_and_get.py
177-
shared_axis_across_figures.py
178-
shared_axis_demo.py
179-
simple3d_oo.py
180-
simple3d.py
181-
simple_plot_fps.py
182-
simple_plot.py
183-
specgram_demo.py
184-
spy_demos.py
185-
stem_plot.py
186-
step_demo.py
187-
stock_demo.py
188-
strip_chart_demo.py
189-
subplot_demo.py
190-
subplots_adjust.py
191-
subplot_toolbar.py
192-
system_monitor.py
193-
table_demo.py
194-
tex_demo.py
195-
text_handles.py
196-
text_rotation.py
197-
text_themes.py
198-
tex_unicode_demo.py
199-
toggle_images.py
200-
to_numeric.py
166+
pythonic_matplotlib.py O
167+
quadmesh_demo.py [MASKED VALUES NOT QUITE RIGHT]
168+
quiver_demo.py [SEGFAULTS]
169+
rc_traits.py [N/A]
170+
scatter_custom_symbol.py O
171+
scatter_demo2.py O
172+
scatter_demo.py O
173+
scatter_masked.py O
174+
scatter_profile.py O
175+
scatter_star_poly.py O [SOME BUGS IN TRUNK -- FIXED ON BRANCH]
176+
set_and_get.py O
177+
shared_axis_across_figures.py O
178+
shared_axis_demo.py O
179+
simple3d_oo.py [PUNTING ON 3D FOR NOW]
180+
simple3d.py [PUNTING ON 3D FOR NOW]
181+
simple_plot_fps.py O
182+
simple_plot.py O
183+
specgram_demo.py O
184+
spy_demos.py O
185+
stem_plot.py O
186+
step_demo.py O
187+
stock_demo.py O
188+
strip_chart_demo.py [REQUIRES GTK]
189+
subplot_demo.py O
190+
subplots_adjust.py O
191+
subplot_toolbar.py O
192+
system_monitor.py O
193+
table_demo.py
194+
tex_demo.py O
195+
text_handles.py O
196+
text_rotation.py O
197+
text_themes.py O
198+
tex_unicode_demo.py O
199+
toggle_images.py [???]
200+
to_numeric.py [REQUIRES PIL]
201201
transoffset.py
202-
two_scales.py
203-
unicode_demo.py
204-
vertical_ticklabels.py
205-
vline_demo.py
206-
webapp_demo.py
207-
wxcursor_demo.py
208-
xcorr_demo.py
209-
zoom_window.py
210-
zorder_demo.py
202+
two_scales.py O
203+
unicode_demo.py O
204+
vertical_ticklabels.py O
205+
vline_demo.py O
206+
webapp_demo.py
207+
wxcursor_demo.py
208+
xcorr_demo.py O
209+
zoom_window.py O
210+
zorder_demo.py O

‎examples/to_numeric.py

Copy file name to clipboardExpand all lines: examples/to_numeric.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
s = agg.tostring_rgb()
1818

1919
# get the width and the height to resize the matrix
20-
l,b,w,h = agg.figure.bbox.get_bounds()
20+
l,b,w,h = agg.figure.bbox.bounds
2121
w, h = int(w), int(h)
2222

2323

‎lib/matplotlib/axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes.py
+4-5Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,9 +1196,9 @@ def autoscale_view(self, tight=False, scalex=True, scaley=True):
11961196
len(self.lines)==0 and
11971197
len(self.patches)==0)):
11981198

1199-
if scalex: self.set_xbound(self.dataLim.intervalx().get_bounds())
1199+
if scalex: self.set_xbound(self.dataLim.intervalx)
12001200

1201-
if scaley: self.set_ybound(self.dataLim.intervaly().get_bounds())
1201+
if scaley: self.set_ybound(self.dataLim.intervaly)
12021202
return
12031203

12041204
if scalex:
@@ -4107,7 +4107,6 @@ def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None,
41074107

41084108
if sym is not None:
41094109
if symstyle==0:
4110-
41114110
collection = mcoll.RegularPolyCollection(
41124111
self.figure.dpi,
41134112
numsides, rotation, scales,
@@ -4143,7 +4142,7 @@ def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None,
41434142
verts /= rescale
41444143

41454144
scales = npy.asarray(scales)
4146-
scales = npy.sqrt(scales * self.figure.dpi.get() / 72.)
4145+
scales = npy.sqrt(scales * self.figure.dpi / 72.)
41474146
if len(scales)==1:
41484147
verts = [scales[0]*verts]
41494148
else:
@@ -4858,7 +4857,7 @@ def psd(self, x, NFFT=256, Fs=2, detrend=mlab.detrend_none,
48584857
self.set_xlabel('Frequency')
48594858
self.set_ylabel('Power Spectrum (dB)')
48604859
self.grid(True)
4861-
vmin, vmax = self.viewLim.intervaly().get_bounds()
4860+
vmin, vmax = self.viewLim.intervaly
48624861
intv = vmax-vmin
48634862
logi = int(npy.log10(intv))
48644863
if logi==0: logi=.1

‎lib/matplotlib/collections.py

Copy file name to clipboardExpand all lines: lib/matplotlib/collections.py
+50-93Lines changed: 50 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ def __init__(self,
7878
**kwargs
7979
):
8080
"""
81-
Create a PatchCollection
81+
Create a Collection
8282
83-
%(PatchCollection)s
83+
%(Collection)s
8484
"""
8585
artist.Artist.__init__(self)
8686
cm.ScalarMappable.__init__(self, norm, cmap)
@@ -103,8 +103,9 @@ def __init__(self,
103103
self._uniform_offsets = None
104104
self._offsets = npy.zeros((1, 2))
105105
if offsets is not None:
106-
# if len(offsets.shape) == 1:
107-
# offsets = offsets[npy.newaxis,:] # Make it Nx2.
106+
offsets = npy.asarray(offsets, npy.float_)
107+
if len(offsets.shape) == 1:
108+
offsets = offsets[npy.newaxis,:] # Make it Nx2.
108109
if transOffset is not None:
109110
Affine2D = transforms.Affine2D
110111
self._offsets = offsets
@@ -171,7 +172,10 @@ def draw(self, renderer):
171172
if not transform.is_affine:
172173
paths = [transform.transform_path_non_affine(path) for path in paths]
173174
transform = transform.get_affine()
174-
175+
if not transOffset.is_affine:
176+
offsets = transOffset.transform_non_affine(offsets)
177+
transOffset = transOffset.get_affine()
178+
175179
renderer.draw_path_collection(
176180
transform, self.clipbox, clippath, clippath_trans,
177181
paths, self.get_transforms(),
@@ -353,7 +357,7 @@ def update_scalarmappable(self):
353357
#print 'update_scalarmappable: self._A', self._A
354358
if self._A is None: return
355359
if len(self._A.shape)>1:
356-
raise ValueError('PatchCollections can only map rank 1 arrays')
360+
raise ValueError('Collections can only map rank 1 arrays')
357361
if len(self._facecolors):
358362
self._facecolors = self.to_rgba(self._A, self._alpha)
359363
else:
@@ -410,32 +414,44 @@ class QuadMesh(Collection):
410414
(0, 2) .. (0, meshWidth), (1, 0), (1, 1), and so on.
411415
"""
412416
def __init__(self, meshWidth, meshHeight, coordinates, showedges):
417+
Path = path.Path
418+
413419
Collection.__init__(self)
414420
self._meshWidth = meshWidth
415421
self._meshHeight = meshHeight
416422
self._coordinates = coordinates
417423
self._showedges = showedges
418-
419-
def get_verts(self, dataTrans=None):
420-
return self._coordinates;
424+
425+
# MGDTODO: Numpify
426+
coordinates = coordinates.reshape((meshHeight + 1, meshWidth + 1, 2))
427+
c = coordinates
428+
paths = []
429+
# We could let the Path constructor generate the codes for us,
430+
# but this is faster, since we know they'll always be the same
431+
codes = npy.array([Path.MOVETO, Path.LINETO, Path.LINETO, Path.LINETO])
432+
for m in xrange(meshHeight):
433+
for n in xrange(meshWidth):
434+
paths.append(Path(
435+
[c[m , n],
436+
c[m , n+1],
437+
c[m+1, n+1],
438+
c[m+1, n]],
439+
codes))
440+
self._paths = paths
441+
442+
def get_paths(self, dataTrans=None):
443+
return self._paths
421444

422445
def draw(self, renderer):
423-
# does not call update_scalarmappable, need to update it
424-
# when creating/changing ****** Why not? speed?
425-
if not self.get_visible(): return
426-
transform = self.get_transform()
427-
transoffset = self._transOffset
428-
transform.freeze()
429-
transoffset.freeze()
430-
#print 'QuadMesh draw'
431446
self.update_scalarmappable() #######################
432447

433-
renderer.draw_quad_mesh( self._meshWidth, self._meshHeight,
434-
self._facecolors, self._coordinates[:,0],
435-
self._coordinates[:, 1], self.clipbox, transform,
436-
self._offsets, transoffset, self._showedges)
437-
transform.thaw()
438-
transoffset.thaw()
448+
self._linewidths = (1,)
449+
if self._showedges:
450+
self._edgecolors = npy.array([[0.0, 0.0, 0.0, 1.0]], npy.float_)
451+
else:
452+
self._edgecolors = self._facecolors
453+
454+
Collection.draw(self, renderer)
439455

440456
class PolyCollection(Collection):
441457
def __init__(self, verts, **kwargs):
@@ -476,6 +492,8 @@ def __init__(self, xranges, yrange, **kwargs):
476492
__init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd
477493

478494
class RegularPolyCollection(Collection):
495+
_path_generator = path.Path.unit_regular_polygon
496+
479497
def __init__(self,
480498
dpi,
481499
numsides,
@@ -514,18 +532,16 @@ def __init__(self,
514532
offsets = offsets,
515533
transOffset = ax.transData,
516534
)
517-
518-
519535
"""
520536
Collection.__init__(self,**kwargs)
521537
self._sizes = sizes
522538
self._dpi = dpi
523-
self._paths = [path.Path.unit_regular_polygon(numsides)]
539+
self._paths = [self._path_generator(numsides)]
524540
# sizes is the area of the circle circumscribing the polygon
525541
# in points^2
526542
self._transforms = [
527-
transforms.Affine2D().rotate(rotation).scale(
528-
(math.sqrt(x) * self._dpi / 72.0) * (1.0 / math.sqrt(math.pi)))
543+
transforms.Affine2D().rotate(-rotation).scale(
544+
(math.sqrt(x) * self._dpi / 72.0) / math.sqrt(math.pi))
529545
for x in sizes]
530546
self.set_transform(transforms.IdentityTransform())
531547

@@ -554,72 +570,13 @@ def get_transformed_patches(self):
554570

555571

556572
class StarPolygonCollection(RegularPolyCollection):
557-
def __init__(self,
558-
dpi,
559-
numsides,
560-
rotation = 0 ,
561-
sizes = (1,),
562-
**kwargs):
563-
"""
564-
Draw a regular star like Polygone with numsides.
565-
566-
* dpi is the figure dpi instance, and is required to do the
567-
area scaling.
568-
569-
* numsides: the number of sides of the polygon
570-
571-
* sizes gives the area of the circle circumscribing the
572-
regular polygon in points^2
573-
574-
* rotation is the rotation of the polygon in radians
575-
576-
%(Collection)s
577-
"""
578-
579-
RegularPolyCollection.__init__(self, dpi, numsides, rotation, sizes, **kwargs)
580-
__init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd
581-
582-
def _update_verts(self):
583-
scale = 1.0/math.sqrt(math.pi)
584-
ns2 = self.numsides*2
585-
r = scale*npy.ones(ns2)
586-
r[1::2] *= 0.5
587-
theta = (math.pi/self.numsides)*npy.arange(ns2) + self.rotation
588-
self._verts = zip( r*npy.sin(theta), r*npy.cos(theta) )
589-
573+
_path_generator = path.Path.unit_regular_star
574+
575+
590576
class AsteriskPolygonCollection(RegularPolyCollection):
591-
def __init__(self,
592-
dpi,
593-
numsides,
594-
rotation = 0 ,
595-
sizes = (1,),
596-
**kwargs):
597-
"""
598-
Draw a regular asterisk Polygone with numsides spikes.
599-
600-
* dpi is the figure dpi instance, and is required to do the
601-
area scaling.
602-
603-
* numsides: the number of spikes of the polygon
604-
605-
* sizes gives the area of the circle circumscribing the
606-
regular polygon in points^2
607-
608-
* rotation is the rotation of the polygon in radians
609-
610-
%(Collection)s
611-
"""
612-
613-
RegularPolyCollection.__init__(self, dpi, numsides, rotation, sizes, **kwargs)
614-
__init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd
615-
616-
def _update_verts(self):
617-
scale = 1.0/math.sqrt(math.pi)
618-
r = scale*npy.ones(self.numsides*2)
619-
r[1::2] = 0
620-
theta = (math.pi/self.numsides)*npy.arange(2*self.numsides) + self.rotation
621-
self._verts = zip( r*npy.sin(theta), r*npy.cos(theta) )
622-
577+
_path_generator = path.Path.unit_regular_asterisk
578+
579+
623580
class LineCollection(Collection, cm.ScalarMappable):
624581
"""
625582
All parameters must be sequences or scalars; if scalars, they will

‎lib/matplotlib/figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/figure.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ def _update_this(self, s, val):
106106
class Figure(Artist):
107107

108108
def __str__(self):
109-
return "Figure(%gx%g)"%(self.bbox.max)
110-
# return "Figure(%gx%g)"%(self.figwidth.get(),self.figheight.get())
109+
return "Figure(%gx%g)" % tuple(self.bbox.size)
111110

112111
def __init__(self,
113112
figsize = None, # defaults to rc figure.figsize

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.