I've been trying to change the linestyles in a LineCollection, but without any success... If I'm using: col = collections.LineCollection(listXY, linewidths=circwdt, colors=circcol, linestyle='solid', label=plabel) it works fine, but anything other than 'solid' gives me an error when the code calls FigureCanvasAgg.draw(self) (it is a wxpython app): Traceback (most recent call last): File "/home/guano/Arbeit/Stout/StereoPanel.py", line 552, 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 >From the MPL docs, I see that i should be able to use other linestyles: http://matplotlib.sourceforge.net/api/collections_api.html#matplotlib.collections.LineCollection linestyles [ ‘solid’ | ‘dashed’ | ‘dashdot’ | ‘dotted’ ] a string or dash tuple. The dash tuple is: I'm using MPL 0.99.0 in Ubuntu Karmic (9.10) tks -- 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.
I can't reproduce the error on 0.99. Can you provide a complete script that reproduces the error? Mike Carlos Grohmann wrote: > I've been trying to change the linestyles in a LineCollection, but > without any success... > > If I'm using: > col = collections.LineCollection(listXY, linewidths=circwdt, > colors=circcol, linestyle='solid', label=plabel) > > it works fine, but anything other than 'solid' gives me an error when > the code calls FigureCanvasAgg.draw(self) (it is a wxpython app): > > Traceback (most recent call last): > File "/home/guano/Arbeit/Stout/StereoPanel.py", line 552, 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 > > > > >From the MPL docs, I see that i should be able to use other linestyles: > > http://matplotlib.sourceforge.net/api/collections_api.html#matplotlib.collections.LineCollection > > linestyles [ ‘solid’ | ‘dashed’ | ‘dashdot’ | ‘dotted’ ] > a string or dash tuple. The dash tuple is: > > > > I'm using MPL 0.99.0 in Ubuntu Karmic (9.10) > > tks > > > -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA
Here. I found out that if I use from pylab import * as in the example, it works. But in my app, I'm using import wx import matplotlib from matplotlib.figure import Figure from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg from matplotlib.font_manager import fontManager, FontProperties from matplotlib.collections import LineCollection could that be the culprit? Carlos script: from pylab import * import numpy as np from matplotlib.collections import LineCollection # We need to set the plot limits, the will not autoscale ax = axes() ax.set_xlim((-1,1)) ax.set_ylim((-1,1)) strike = [0,45,90,135] dip = [10,20,30,40] listXY = [] for i in range(len(strike)): beta = np.radians(strike[i]) phi = np.radians(np.arange(-90,92,2)) lamb = np.radians((90 - dip[i])) alpha = np.arccos(np.cos(phi) * np.cos(lamb)) tq = np.sqrt(2) * np.sin(alpha/2) sint = np.sin(phi) / np.sin(alpha) temps = 1 - (sint * sint) x = tq * np.sqrt(temps) y = tq * sint x1 = np.cos(beta) * x + np.sin(beta) * y y1 = -np.sin(beta) * x + np.cos(beta) * y listXY.append(zip(x1,y1)) col = LineCollection(listXY, linewidths=1, colors='red', linestyles = 'dotted') ax.add_collection(col, autolim=True) show() On Wed, Apr 28, 2010 at 09:46, Michael Droettboom <md...@st...> wrote: > I can't reproduce the error on 0.99. Can you provide a complete script that > reproduces the error? > > Mike > > Carlos Grohmann wrote: >> >> I've been trying to change the linestyles in a LineCollection, but >> without any success... >> >> If I'm using: >> col = collections.LineCollection(listXY, linewidths=circwdt, >> colors=circcol, linestyle='solid', label=plabel) >> >> it works fine, but anything other than 'solid' gives me an error when >> the code calls FigureCanvasAgg.draw(self) (it is a wxpython app): >> >> Traceback (most recent call last): >> File "/home/guano/Arbeit/Stout/StereoPanel.py", line 552, 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 >> >> >> >> >From the MPL docs, I see that i should be able to use other linestyles: >> >> >> http://matplotlib.sourceforge.net/api/collections_api.html#matplotlib.collections.LineCollection >> >> linestyles [ ‘solid’ | ‘dashed’ | ‘dashdot’ | ‘dotted’ ] >> a string or dash tuple. The dash tuple is: >> >> >> >> I'm using MPL 0.99.0 in Ubuntu Karmic (9.10) >> >> tks >> >> >> > > -- > Michael Droettboom > Science Software Branch > Operations and Engineering Division > Space Telescope Science Institute > Operated by AURA for NASA > > -- 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.
Hi there I found that the error is related to legend! If I disable self.plotaxes.legend(bbox_to_anchor=(0.95, 0.95), loc=2, prop=FontProperties(size='small'),numpoints=1) I can change the linestyles and it works like a charm, but if I turn on that line again... just errors. can anyone think of something? best Carlos On Wed, Apr 28, 2010 at 09:46, Michael Droettboom <md...@st...> wrote: > I can't reproduce the error on 0.99. Can you provide a complete script that > reproduces the error? > > Mike > > Carlos Grohmann wrote: >> >> I've been trying to change the linestyles in a LineCollection, but >> without any success... >> >> If I'm using: >> col = collections.LineCollection(listXY, linewidths=circwdt, >> colors=circcol, linestyle='solid', label=plabel) >> >> it works fine, but anything other than 'solid' gives me an error when >> the code calls FigureCanvasAgg.draw(self) (it is a wxpython app): >> >> Traceback (most recent call last): >> File "/home/guano/Arbeit/Stout/StereoPanel.py", line 552, 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 >> >> >> >> >From the MPL docs, I see that i should be able to use other linestyles: >> >> >> http://matplotlib.sourceforge.net/api/collections_api.html#matplotlib.collections.LineCollection >> >> linestyles [ ‘solid’ | ‘dashed’ | ‘dashdot’ | ‘dotted’ ] >> a string or dash tuple. The dash tuple is: >> >> >> >> I'm using MPL 0.99.0 in Ubuntu Karmic (9.10) >> >> tks >> >> >> > > -- > Michael Droettboom > Science Software Branch > Operations and Engineering Division > Space Telescope Science Institute > Operated by AURA for NASA > > -- 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.