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

Skip to content

Commit 034070b

Browse files
committed
added MA fix for lines
svn path=/trunk/matplotlib/; revision=1542
1 parent e84e171 commit 034070b

3 files changed

Lines changed: 37 additions & 43 deletions

File tree

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
New entries should be added at the top
22

3+
2005-07-07 Added Eric's MA set_xdata Line2D fix - JDH
4+
35
2005-07-06 Made HOME/.matplotlib the new config dir where the
46
matplotlibrc file, the ttf.cache, and the tex.cache live.
57
The new default filenames in .matplotlib have no leading

lib/matplotlib/axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def _process_plot_format(fmt):
8080
linestyle = 'None'
8181
marker = 'None'
8282
color = rcParams['lines.color']
83-
83+
8484
# handle the multi char special cases and strip them from the
8585
# string
8686
if fmt.find('--')>=0:

lib/matplotlib/lines.py

Lines changed: 34 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -131,18 +131,18 @@ class Line2D(Artist):
131131

132132
def __init__(self, xdata, ydata,
133133
linewidth = None, # all Nones default to rc
134-
linestyle = None,
135-
color = None,
136-
marker = None,
137-
markersize = None,
138-
markeredgewidth = None,
139-
markeredgecolor = None,
140-
markerfacecolor = None,
141-
antialiased = None,
134+
linestyle = None,
135+
color = None,
136+
marker = None,
137+
markersize = None,
138+
markeredgewidth = None,
139+
markeredgecolor = None,
140+
markerfacecolor = None,
141+
antialiased = None,
142142
dash_capstyle = None,
143-
solid_capstyle = None,
143+
solid_capstyle = None,
144144
dash_joinstyle = None,
145-
solid_joinstyle = None,
145+
solid_joinstyle = None,
146146
**kwargs
147147
):
148148
"""
@@ -218,7 +218,7 @@ def __init__(self, xdata, ydata,
218218
self._logcache = None
219219

220220
if len(kwargs): setp(self, **kwargs)
221-
221+
222222
def get_window_extent(self, renderer):
223223
self._newstyle = hasattr(renderer, 'draw_markers')
224224
if self._newstyle:
@@ -262,40 +262,32 @@ def set_data(self, *args):
262262
try: del self._xc, self._yc
263263
except AttributeError: pass
264264

265-
self._masked_x = None
266-
self._masked_y = None
265+
self._x_orig = x
266+
self._y_orig = y
267+
268+
x = ma.ravel(x)
269+
y = ma.ravel(y)
270+
if len(x)==1 and len(y)>1:
271+
x = x * ones(y.shape, Float)
272+
if len(y)==1 and len(x)>1:
273+
y = y * ones(x.shape, Float)
274+
275+
if len(x) != len(y):
276+
raise RuntimeError('xdata and ydata must be the same length')
277+
267278
mx = ma.getmask(x)
268279
my = ma.getmask(y)
269-
if mx is not None:
270-
mx = ravel(mx)
271-
self._masked_x = x
272-
if my is not None:
273-
my = ravel(my)
274-
self._masked_y = y
275280
mask = ma.mask_or(mx, my)
276281
if mask is not None:
277-
x = ma.masked_array(ma.ravel(x), mask=mask).compressed()
278-
y = ma.masked_array(ma.ravel(y), mask=mask).compressed()
282+
x = ma.masked_array(x, mask=mask).compressed()
283+
y = ma.masked_array(y, mask=mask).compressed()
279284
self._segments = unmasked_index_ranges(mask)
280285
else:
281286
self._segments = None
282287

283288
self._x = asarray(x, Float)
284289
self._y = asarray(y, Float)
285290

286-
if len(self._x.shape)>1:
287-
self._x = ravel(self._x)
288-
if len(self._y.shape)>1:
289-
self._y = ravel(self._y)
290-
291-
# What is the rationale for the following two lines?
292-
# And why is there not a similar pair with _x and _y reversed?
293-
if len(self._y)==1 and len(self._x)>1:
294-
self._y = self._y*ones(self._x.shape, Float)
295-
296-
if len(self._x) != len(self._y):
297-
raise RuntimeError('xdata and ydata must be the same length')
298-
299291
if self._useDataClipping: self._xsorted = self._is_sorted(self._x)
300292

301293
self._logcache = None
@@ -373,7 +365,7 @@ def draw(self, renderer):
373365
cap = self._solidcapstyle
374366
join = self._solidjoinstyle
375367
gc.set_joinstyle(join)
376-
gc.set_capstyle(cap)
368+
gc.set_capstyle(cap)
377369

378370
if self._newstyle:
379371
# transform in backend
@@ -420,13 +412,13 @@ def get_markeredgewidth(self): return self._markeredgewidth
420412
def get_markerfacecolor(self): return self._markerfacecolor
421413
def get_markersize(self): return self._markersize
422414
def get_xdata(self, valid_only = False):
423-
if self._masked_x is None or valid_only:
415+
if valid_only:
424416
return self._x
425-
return self._masked_x
417+
return self._x_orig
426418
def get_ydata(self, valid_only = False):
427-
if self._masked_y is None or valid_only:
419+
if valid_only:
428420
return self._y
429-
return self._masked_y
421+
return self._y_orig
430422

431423

432424
def _set_clip(self):
@@ -1231,7 +1223,7 @@ def get_ms(self):
12311223
def set_dash_joinstyle(self, s):
12321224
"""
12331225
Set the join style for dashed linestyles
1234-
ACCEPTS: ['miter' | 'round' | 'bevel']
1226+
ACCEPTS: ['miter' | 'round' | 'bevel']
12351227
"""
12361228
s = s.lower()
12371229
if s not in self.validJoin:
@@ -1241,7 +1233,7 @@ def set_dash_joinstyle(self, s):
12411233
def set_solid_joinstyle(self, s):
12421234
"""
12431235
Set the join style for solid linestyles
1244-
ACCEPTS: ['miter' | 'round' | 'bevel']
1236+
ACCEPTS: ['miter' | 'round' | 'bevel']
12451237
"""
12461238
s = s.lower()
12471239
if s not in self.validJoin:
@@ -1271,7 +1263,7 @@ def set_dash_capstyle(self, s):
12711263
raise ValueError('set_dash_capstyle passed "%s"; valid capstyles are %s'%(s, self.validJoin))
12721264

12731265
self._dashcapstyle = s
1274-
1266+
12751267

12761268
def set_solid_capstyle(self, s):
12771269
"""

0 commit comments

Comments
 (0)