From: Carlos G. <car...@gm...> - 2010-04-30 17:30:08
|
Hi all, I'm wirking on a wxpython app, and I realized that the legend of a matplotlib plot only works with solid lines. If I change the linestyles to dashed, dotted or dashdot, it gives an error: Traceback (most recent call last): File "/home/guano/Arbeit/Stout/StereoPanel.py", line 551, in PlotChecked self.stereoCanvas.draw() File "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_wxagg.py", line 59, in draw FigureCanvasAgg.draw(self) File "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_agg.py", line 314, in draw self.figure.draw(self.renderer) File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 46, in draw_wrapper draw(artist, renderer, *kl) File "/usr/lib/pymodules/python2.6/matplotlib/figure.py", line 774, in draw for a in self.axes: a.draw(renderer) File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 46, in draw_wrapper draw(artist, renderer, *kl) File "/usr/lib/pymodules/python2.6/matplotlib/axes.py", line 1721, in draw a.draw(renderer) File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 46, in draw_wrapper draw(artist, renderer, *kl) File "/usr/lib/pymodules/python2.6/matplotlib/legend.py", line 386, in draw self._legend_box.draw(renderer) File "/usr/lib/pymodules/python2.6/matplotlib/offsetbox.py", line 224, in draw c.draw(renderer) File "/usr/lib/pymodules/python2.6/matplotlib/offsetbox.py", line 224, in draw c.draw(renderer) File "/usr/lib/pymodules/python2.6/matplotlib/offsetbox.py", line 224, in draw c.draw(renderer) File "/usr/lib/pymodules/python2.6/matplotlib/offsetbox.py", line 224, in draw c.draw(renderer) File "/usr/lib/pymodules/python2.6/matplotlib/offsetbox.py", line 488, in draw c.draw(renderer) File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 46, in draw_wrapper draw(artist, renderer, *kl) File "/usr/lib/pymodules/python2.6/matplotlib/lines.py", line 535, in draw drawFunc(renderer, gc, tpath, affine.frozen()) File "/usr/lib/pymodules/python2.6/matplotlib/lines.py", line 874, in _draw_lines self._lineFunc(renderer, gc, path, trans) File "/usr/lib/pymodules/python2.6/matplotlib/lines.py", line 925, in _draw_dashed renderer.draw_path(gc, path, trans) File "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_agg.py", line 98, in draw_path self._renderer.draw_path(gc, path, transform, rgbFace) TypeError: float() argument must be a string or a number This happens for Line2D and for LineCollection as well. TIA Carlos -- Prof. Carlos Henrique Grohmann - Geologist D.Sc. Institute of Geosciences - Univ. of São Paulo, Brazil http://www.igc.usp.br/pessoais/guano Linux User #89721 ________________ Can’t stop the signal. |
From: Michael D. <md...@st...> - 2010-04-30 17:35:37
|
The following works for me. from pylab import * plot([1,2,3], linestyle='dashed', label='foo') legend() show() Can you be more specific about how you create the error? Mike Carlos Grohmann wrote: > Hi all, > > I'm wirking on a wxpython app, and I realized that the legend of a > matplotlib plot only works with solid lines. If I change the > linestyles to dashed, dotted or dashdot, it gives an error: > > Traceback (most recent call last): > File "/home/guano/Arbeit/Stout/StereoPanel.py", line 551, in PlotChecked > self.stereoCanvas.draw() > File "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_wxagg.py", > line 59, in draw > FigureCanvasAgg.draw(self) > File "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_agg.py", > line 314, in draw > self.figure.draw(self.renderer) > File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 46, > in draw_wrapper > draw(artist, renderer, *kl) > File "/usr/lib/pymodules/python2.6/matplotlib/figure.py", line 774, in draw > for a in self.axes: a.draw(renderer) > File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 46, > in draw_wrapper > draw(artist, renderer, *kl) > File "/usr/lib/pymodules/python2.6/matplotlib/axes.py", line 1721, in draw > a.draw(renderer) > File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 46, > in draw_wrapper > draw(artist, renderer, *kl) > File "/usr/lib/pymodules/python2.6/matplotlib/legend.py", line 386, in draw > self._legend_box.draw(renderer) > File "/usr/lib/pymodules/python2.6/matplotlib/offsetbox.py", line 224, in draw > c.draw(renderer) > File "/usr/lib/pymodules/python2.6/matplotlib/offsetbox.py", line 224, in draw > c.draw(renderer) > File "/usr/lib/pymodules/python2.6/matplotlib/offsetbox.py", line 224, in draw > c.draw(renderer) > File "/usr/lib/pymodules/python2.6/matplotlib/offsetbox.py", line 224, in draw > c.draw(renderer) > File "/usr/lib/pymodules/python2.6/matplotlib/offsetbox.py", line 488, in draw > c.draw(renderer) > File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 46, > in draw_wrapper > draw(artist, renderer, *kl) > File "/usr/lib/pymodules/python2.6/matplotlib/lines.py", line 535, in draw > drawFunc(renderer, gc, tpath, affine.frozen()) > File "/usr/lib/pymodules/python2.6/matplotlib/lines.py", line 874, > in _draw_lines > self._lineFunc(renderer, gc, path, trans) > File "/usr/lib/pymodules/python2.6/matplotlib/lines.py", line 925, > in _draw_dashed > renderer.draw_path(gc, path, trans) > File "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_agg.py", > line 98, in draw_path > self._renderer.draw_path(gc, path, transform, rgbFace) > TypeError: float() argument must be a string or a number > > > > This happens for Line2D and for LineCollection as well. > > TIA > > Carlos > > -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA |