Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d10588e

Browse files
committed
added tim leslies 3d patch
svn path=/trunk/matplotlib/; revision=3194
1 parent d65d339 commit d10588e

7 files changed

Lines changed: 61 additions & 45 deletions

File tree

examples/units/evans_test2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Plot with radians from the basic_units mockup example package
33
This example shows how the unit class can determine the tick locating,
4-
formatting and axis labeling
4+
formatting and axis labeling.
55
"""
66
from basic_units import radians, degrees
77
from pylab import figure, show, nx

examples/units/units_sample.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
plot using a variety of cm vs inches conversions. The example shows
33
how default unit instrospection works (ax1), how various keywords can
44
be used to set the x and y units to override the defaults (ax2, ax3,
5-
ax4) and how one can set the xlimits
5+
ax4) and how one can set the xlimits using scalars (ax3, current units
6+
assumed) or units (conversions applied to get the numbers to current
7+
units)
68
79
"""
810
from basic_units import cm, inch

lib/matplotlib/art3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def zalpha(colors, zs):
369369
"""Modify the alphas of the color list according to depth"""
370370
colors = get_colors(colors,len(zs))
371371
norm = Normalize(min(zs),max(zs))
372-
sats = nx.array([1-norm(z)*0.7 for z in zs])
372+
sats = 1 - norm(zs)*0.7
373373
colors = [(c[0],c[1],c[2],c[3]*s) for c,s in zip(colors,sats)]
374374
return colors
375375

lib/matplotlib/axes.py

Lines changed: 52 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from artist import Artist, setp
1717
from axis import XAxis, YAxis
1818
from cbook import iterable, is_string_like, flatten, enumerate, \
19-
allequal, dict_delall, popall, silent_list, is_numlike, dedent
19+
allequal, dict_delall, popd, popall, silent_list, is_numlike, dedent
2020
from collections import RegularPolyCollection, PolyCollection, LineCollection, \
2121
QuadMesh, StarPolygonCollection, BrokenBarHCollection
2222
from colors import colorConverter, Normalize, Colormap, \
@@ -203,15 +203,16 @@ def _get_next_cycle_color(self):
203203
return color
204204

205205
def __call__(self, *args, **kwargs):
206+
kwargs = kwargs.copy()
206207

207208
if self.axes.xaxis is not None and self.axes.xaxis is not None:
208-
xunits = kwargs.pop('xunits', self.axes.xaxis.units)
209-
yunits = kwargs.pop('yunits', self.axes.yaxis.units)
209+
xunits = popd(kwargs, 'xunits', self.axes.xaxis.units)
210+
yunits = popd(kwargs, 'yunits', self.axes.yaxis.units)
210211
if xunits!=self.axes.xaxis.units:
211212
self.axes.xaxis.set_units(xunits)
212213
if yunits!=self.axes.yaxis.units:
213214
self.axes.yaxis.set_units(yunits)
214-
215+
215216
ret = self._grab_next_args(*args, **kwargs)
216217
return ret
217218

@@ -237,7 +238,7 @@ def _xy_from_y(self, y):
237238
if self.axes.yaxis is not None:
238239
b = self.axes.yaxis.update_units(y)
239240
if b: return arange(len(y)), y, False
240-
241+
241242
y = ma.asarray(y)
242243
if len(y.shape) == 1:
243244
y = y[:,newaxis]
@@ -248,12 +249,12 @@ def _xy_from_y(self, y):
248249
return x,y, True
249250

250251
def _xy_from_xy(self, x, y):
251-
if self.axes.xaxis is not None and self.axes.yaxis is not None:
252+
if self.axes.xaxis is not None and self.axes.yaxis is not None:
252253
bx = self.axes.xaxis.update_units(x)
253254
by = self.axes.yaxis.update_units(y)
254255
# right now multicol is not supported if either x or y are
255256
# unit enabled but this can be fixed..
256-
if bx or by: return x, y, False
257+
if bx or by: return x, y, False
257258

258259
x = ma.asarray(x)
259260
y = ma.asarray(y)
@@ -365,6 +366,7 @@ def makefill(x, y):
365366
return ret
366367

367368
def _plot_3_args(self, tup3, **kwargs):
369+
kwargs = kwargs.copy()
368370
ret = []
369371

370372
x, y, fmt = tup3
@@ -1046,7 +1048,7 @@ def add_collection(self, collection, autolim=False):
10461048
if autolim:
10471049
self.update_datalim(collection.get_verts(self.transData))
10481050

1049-
1051+
10501052
def add_line(self, line):
10511053
'Add a line to the list of plot lines'
10521054
self._set_artist_props(line)
@@ -1068,7 +1070,7 @@ def _update_line_limits(self, line):
10681070
ydata = array([y for x,y in xys])
10691071

10701072
self.update_datalim_numerix( xdata, ydata )
1071-
1073+
10721074

10731075
def add_patch(self, p):
10741076
"""
@@ -1081,7 +1083,7 @@ def add_patch(self, p):
10811083
p.set_clip_box(self.bbox)
10821084
self._update_patch_limits(p)
10831085
self.patches.append(p)
1084-
1086+
10851087
def _update_patch_limits(self, p):
10861088
'update the datalimits for patch p'
10871089
xys = self._get_verts_in_data_coords(
@@ -1102,7 +1104,7 @@ def relim(self):
11021104

11031105
for p in self.patches:
11041106
self._update_patch_limits(p)
1105-
1107+
11061108
def update_datalim(self, xys):
11071109
'Update the data lim bbox with seq of xy tups or equiv. 2-D array'
11081110
# if no data is set currently, the bbox will ignore its
@@ -1135,25 +1137,25 @@ def _get_verts_in_data_coords(self, trans, xys):
11351137
def _process_unit_info(self, xdata=None, ydata=None, kwargs=None):
11361138
'look for unit kwargs and update the axis instances as necessary'
11371139

1138-
if self.xaxis is None or self.xaxis is None: return
1140+
if self.xaxis is None or self.xaxis is None: return
11391141

11401142

11411143
if xdata is not None:
11421144
self.xaxis.update_units(xdata)
11431145
#print '_process updated xdata: units=%s, converter=%s'%(self.xaxis.units, self.xaxis.converter)
11441146

11451147
if ydata is not None:
1146-
self.yaxis.update_units(ydata)
1147-
#print '_process updated ydata: units=%s, converter=%s'%(self.yaxis.units, self.yaxis.converter)
1148+
self.yaxis.update_units(ydata)
1149+
#print '_process updated ydata: units=%s, converter=%s'%(self.yaxis.units, self.yaxis.converter)
11481150

11491151
# process kwargs 2nd since these will override default units
11501152
if kwargs is not None:
1151-
xunits = kwargs.pop('xunits', self.xaxis.units)
1153+
xunits = popd(kwargs, 'xunits', self.xaxis.units)
11521154
if xunits!=self.xaxis.units:
11531155
self.xaxis.set_units(xunits)
11541156
#print '_process updated xunits kws: units=%s, converter=%s'%(self.xaxis.units, self.xaxis.converter)
11551157

1156-
yunits = kwargs.pop('yunits', self.yaxis.units)
1158+
yunits = popd(kwargs, 'yunits', self.yaxis.units)
11571159
if yunits!=self.yaxis.units:
11581160
self.yaxis.set_units(yunits)
11591161
#print '_process updated yunits kws: units=%s, converter=%s'%(self.yaxis.units, self.yaxis.converter)
@@ -2241,6 +2243,7 @@ def axhspan(self, ymin, ymax, xmin=0, xmax=1, **kwargs):
22412243
%(Polygon)s
22422244
"""
22432245
# convert y axis units
2246+
kwargs = kwargs.copy()
22442247

22452248
trans = blend_xy_sep_transform( self.transAxes, self.transData )
22462249
verts = (xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, ymin)
@@ -2282,6 +2285,7 @@ def axvspan(self, xmin, xmax, ymin=0, ymax=1, **kwargs):
22822285
%(Polygon)s
22832286
"""
22842287
# convert x axis units
2288+
kwargs = kwargs.copy()
22852289
trans = blend_xy_sep_transform( self.transData, self.transAxes )
22862290
verts = [(xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, ymin)]
22872291
p = Polygon(verts, **kwargs)
@@ -2515,16 +2519,17 @@ def plot(self, *args, **kwargs):
25152519
information
25162520
"""
25172521

2518-
scalex = kwargs.pop('scalex', True)
2519-
scaley = kwargs.pop('scaley', True)
2522+
kwargs = kwargs.copy()
2523+
scalex = popd(kwargs, 'scalex', True)
2524+
scaley = popd(kwargs, 'scaley', True)
25202525

25212526
if not self._hold: self.cla()
25222527
lines = []
25232528

25242529
for line in self._get_lines(*args, **kwargs):
25252530
self.add_line(line)
25262531
lines.append(line)
2527-
2532+
25282533

25292534
self.autoscale_view(scalex=scalex, scaley=scaley)
25302535
return lines
@@ -2612,11 +2617,12 @@ def loglog(self, *args, **kwargs):
26122617
%(Line2D)s
26132618
"""
26142619
if not self._hold: self.cla()
2615-
dx = {'basex': kwargs.pop('basex', 10),
2616-
'subsx': kwargs.pop('subsx', None),
2620+
kwargs = kwargs.copy()
2621+
dx = {'basex': popd(kwargs,'basex', 10),
2622+
'subsx': popd(kwargs,'subsx', None),
26172623
}
2618-
dy = {'basey': kwargs.pop('basey', 10),
2619-
'subsy': kwargs.pop('subsy', None),
2624+
dy = {'basey': popd(kwargs,'basey', 10),
2625+
'subsy': popd(kwargs,'subsy', None),
26202626
}
26212627

26222628
self.set_xscale('log', **dx)
@@ -2651,8 +2657,9 @@ def semilogx(self, *args, **kwargs):
26512657
%(Line2D)s
26522658
"""
26532659
if not self._hold: self.cla()
2654-
d = {'basex': kwargs.pop('basex', 10),
2655-
'subsx': kwargs.pop('subsx', None),
2660+
kwargs = kwargs.copy()
2661+
d = {'basex': popd(kwargs, 'basex', 10),
2662+
'subsx': popd(kwargs, 'subsx', None),
26562663
}
26572664

26582665
self.set_xscale('log', **d)
@@ -2685,8 +2692,9 @@ def semilogy(self, *args, **kwargs):
26852692
26862693
"""
26872694
if not self._hold: self.cla()
2688-
d = {'basey': kwargs.pop('basey', 10),
2689-
'subsy': kwargs.pop('subsy', None),
2695+
kwargs = kwargs.copy()
2696+
d = {'basey': popd(kwargs,'basey', 10),
2697+
'subsy': popd(kwargs,'subsy', None),
26902698
}
26912699
self.set_yscale('log', **d)
26922700
b = self._hold
@@ -2791,6 +2799,7 @@ def xcorr(self, x, y, normed=False, detrend=detrend_none, usevlines=False,
27912799
a = self.vlines(lags, [0], c, **kwargs)
27922800
b = self.axhline(**kwargs)
27932801
else:
2802+
kwargs = kwargs.copy()
27942803
kwargs.setdefault('marker', 'o')
27952804
kwargs.setdefault('linestyle', 'None')
27962805
a, = self.plot(lags, c, **kwargs)
@@ -2862,6 +2871,7 @@ def legend(self, *args, **kwargs):
28622871
handletextsep = 0.02 # the space between the legend line and legend text
28632872
axespad = 0.02 # the border between the axes and legend edge
28642873
"""
2874+
kwargs = kwargs.copy()
28652875
def get_handles():
28662876
handles = self.lines
28672877
handles.extend(self.patches)
@@ -2878,13 +2888,13 @@ def get_handles():
28782888
if label != '_nolegend_':
28792889
handles.append(line)
28802890
labels.append(label)
2881-
loc = kwargs.pop('loc', 1)
2891+
loc = popd(kwargs, 'loc', 1)
28822892

28832893
elif len(args)==1:
28842894
# LABELS
28852895
labels = args[0]
28862896
handles = [h for h, label in zip(get_handles(), labels)]
2887-
loc = kwargs.pop('loc', 1)
2897+
loc = popd(kwargs, 'loc', 1)
28882898

28892899
elif len(args)==2:
28902900
if is_string_like(args[1]) or isinstance(args[1], int):
@@ -2894,7 +2904,7 @@ def get_handles():
28942904
else:
28952905
# LINES, LABELS
28962906
handles, labels = args
2897-
loc = kwargs.pop('loc', 1)
2907+
loc = popd(kwargs, 'loc', 1)
28982908

28992909
elif len(args)==3:
29002910
# LINES, LABELS, LOC
@@ -3783,6 +3793,7 @@ def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None,
37833793
'8' : (8,0), # octagon
37843794
}
37853795

3796+
kwargs = kwargs.copy()
37863797
self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs)
37873798

37883799
x, y, s, c = delete_masked_points(x, y, s, c)
@@ -4076,14 +4087,15 @@ def quiver_classic(self, U, V, *args, **kwargs ):
40764087
V = V*(S/Nmax)
40774088
N = N*Nmax
40784089

4079-
alpha = kwargs.pop('alpha', 1.0)
4080-
width = kwargs.pop('width', .5)
4081-
norm = kwargs.pop('norm', None)
4082-
cmap = kwargs.pop('cmap', None)
4083-
vmin = kwargs.pop('vmin', None)
4084-
vmax = kwargs.pop('vmax', None)
4085-
color = kwargs.pop('color', None)
4086-
shading = kwargs.pop('shading', 'faceted')
4090+
kwargs = kwargs.copy()
4091+
alpha = popd(kwargs,'alpha', 1.0)
4092+
width = popd(kwargs,'width', .5)
4093+
norm = popd(kwargs,'norm', None)
4094+
cmap = popd(kwargs,'cmap', None)
4095+
vmin = popd(kwargs,'vmin', None)
4096+
vmax = popd(kwargs,'vmax', None)
4097+
color = popd(kwargs,'color', None)
4098+
shading = popd(kwargs,'shading', 'faceted')
40874099

40884100
if len(kwargs):
40894101
raise TypeError, "quiver() got an unexpected keyword argument '%s'"%kwargs.keys()[0]
@@ -4158,6 +4170,8 @@ def fill(self, *args, **kwargs):
41584170
kwargs control the Polygon properties:
41594171
%(Polygon)s
41604172
"""
4173+
kwargs = kwargs.copy()
4174+
41614175
if not self._hold: self.cla()
41624176

41634177
patches = []

lib/matplotlib/mpl-data/matplotlibrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#### CONFIGURATION BEGINS HERE
2727
# the default backend; one of GTK GTKAgg GTKCairo FltkAgg QtAgg TkAgg
2828
# Agg Cairo GD GDK Paint PS PDF SVG Template
29-
backend : WXAgg
29+
backend : TkAgg
3030
numerix : numpy # numpy, Numeric or numarray
3131
units : True
3232
#interactive : False # see http://matplotlib.sourceforge.net/interactive.html

lib/matplotlib/patches.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ def __init__(self, xy, **kwargs):
480480

481481

482482
def get_verts(self):
483-
xs, ys = zip(*self.xy)
483+
xs, ys = zip(*self.xy)[:2]
484484
xs = self.convert_xunits(xs)
485485
ys = self.convert_yunits(ys)
486486
return zip(xs, ys)

unit/memleak_gui.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
import matplotlib
1414

1515
#matplotlib.use('TkAgg') # or TkAgg or WxAgg or QtAgg or Gtk
16-
matplotlib.rcParams['toolbar'] = 'toolbar2' # None, classic, toolbar2
17-
#matplotlib.rcParams['toolbar'] = None # None, classic, toolbar2
16+
#matplotlib.rcParams['toolbar'] = 'toolbar2' # None, classic, toolbar2
17+
matplotlib.rcParams['toolbar'] = None # None, classic, toolbar2
1818

1919
import pylab
2020
from matplotlib import _pylab_helpers as ph

0 commit comments

Comments
 (0)