From: <jd...@us...> - 2007-11-02 13:13:42
|
Revision: 4095 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4095&view=rev Author: jdh2358 Date: 2007-11-02 06:13:40 -0700 (Fri, 02 Nov 2007) Log Message: ----------- added Manuel's contour linestyle patch Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/contour.py trunk/matplotlib/lib/matplotlib/mlab.py Modified: trunk/matplotlib/lib/matplotlib/contour.py =================================================================== --- trunk/matplotlib/lib/matplotlib/contour.py 2007-11-02 12:55:51 UTC (rev 4094) +++ trunk/matplotlib/lib/matplotlib/contour.py 2007-11-02 13:13:40 UTC (rev 4095) @@ -390,7 +390,8 @@ self.levels = kwargs.get('levels', None) self.filled = kwargs.get('filled', False) self.linewidths = kwargs.get('linewidths', None) - + self.linestyles = kwargs.get('linestyles', 'solid') + self.alpha = kwargs.get('alpha', 1.0) self.origin = kwargs.get('origin', None) self.extent = kwargs.get('extent', None) @@ -457,11 +458,13 @@ else: tlinewidths = self._process_linewidths() self.tlinewidths = tlinewidths + tlinestyles = self._process_linestyles() C = _cntr.Cntr(x, y, z.filled(), _mask) - for level, width in zip(self.levels, tlinewidths): + for level, width, lstyle in zip(self.levels, tlinewidths, tlinestyles): nlist = C.trace(level, points = 0) col = collections.LineCollection(nlist, - linewidths = width) + linewidths = width, + linestyle = lstyle) if level < 0.0 and self.monochrome: ls = mpl.rcParams['contour.negative_linestyle'] @@ -696,6 +699,18 @@ linewidths = [linewidths] * Nlev tlinewidths = [(w,) for w in linewidths] return tlinewidths + + def _process_linestyles(self): + linestyles = self.linestyles + Nlev = len(self.levels) + if linestyles is None: + tlinestyles = ['solid'] * Nlev + else: + if cbook.is_string_like(linestyles): + tlinestyles = [linestyles] * Nlev + elif cbook.iterable(linestyles) and len(linestyles) < Nlev: + tlinestyles = list(linestyles) * int(npy.ceil(Nlev/len(linestyles))) + return tlinestyles def get_alpha(self): '''For compatibility with artists, return self.alpha''' Modified: trunk/matplotlib/lib/matplotlib/mlab.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mlab.py 2007-11-02 12:55:51 UTC (rev 4094) +++ trunk/matplotlib/lib/matplotlib/mlab.py 2007-11-02 13:13:40 UTC (rev 4095) @@ -811,7 +811,7 @@ """ - x = npy.ravel(x) + x = npy.array(x).ravel() # we need a copy x.sort() Nx = len(x) @@ -1449,7 +1449,7 @@ files is automatic, if the filename ends in .gz """ fh = cbook.to_filehandle(fname, 'w') - writer = csv.writer(fh, delimiter=delimiter) + writer = csv.writer(fh, delimiter=delimiter, quoting=csv.QUOTE_NONNUMERIC) header = r.dtype.names writer.writerow(header) for row in r: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |