From: Jean-Baptiste C. <Jea...@de...> - 2004-03-18 09:29:47
|
S=E6l ! I have installed matplotlib-0.52 and succesfully ran the figlegend example. However when I try to run it directly in my program into a figure i am not = as successful: - I can create the legend with=20 leg=3Dmatplotlib.matlab.figlegend(tuple([i[1] for i in d]),tuple([i[0] for = i in d]),'upper center') leg.draw() But it does not appear anywhere If I try to call figlegend from the canvas, canvas.Figure or canvas.Figure.= axes[0], I get an erro message as figlegend is not defined in any of these = contexts canvas.figure.figlegend(tuple([i[1] for i in d]),tuple([i[0] for i in d]),= 'upper center') AttributeError: Figure instance has no attribute 'figlegend' How can I get my figlegend to appear in my window ? Takk Jean-Baptiste On Fri, 12 Mar 2004 20:17:25 -0800 mat...@li... wrote: > Send Matplotlib-users mailing list submissions to > mat...@li... >=20 > To subscribe or unsubscribe via the World Wide Web, visit > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > or, via email, send a message with subject or body 'help' to > mat...@li... >=20 > You can reach the person managing the list at > mat...@li... >=20 > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Matplotlib-users digest..." >=20 >=20 > Today's Topics: >=20 > 1. invisilbe line (Jean-Baptiste Cazier) > 2. Re: invisilbe line (John Hunter) >=20 > --__--__-- >=20 > Message: 1 > Date: Fri, 12 Mar 2004 12:40:19 +0000 > From: Jean-Baptiste Cazier <Jea...@de...> > To: mat...@li... > Organization: deCODE Genetics > Subject: [Matplotlib-users] invisilbe line >=20 > S=3DE6l ! >=20 >=20 > Is there a way to "turn-off" lines without removing the data ? > My goal is to hide some lines in a plot wihtout losing the data so I can = sh=3D > ow it again later. > I can do=3D20 > # Hide the line > x=3D3Dline.get_xdata() > y=3D3Dline.get_ydata() > line.set_data([],[]) >=20 > # Reset the line > line.set_data(x,y) >=20 > But I would prefer I more elegant way like > line.hide() > line.show() >=20 > Would it be possible to get something like that ? >=20 > Thanks >=20 > Jean-Baptiste >=20 >=20 > --=3D20 > ----------------------------- > Jea...@de... >=20 > Department of Statistics > deCODE genetics Sturlugata,8 > 570 2993 101 Reykjav=3DEDk >=20 >=20 >=20 > --__--__-- >=20 > Message: 2 > To: Jean-Baptiste Cazier <Jea...@de...> > Cc: mat...@li... > Subject: Re: [Matplotlib-users] invisilbe line > From: John Hunter <jdh...@ac...> > Date: Fri, 12 Mar 2004 12:29:18 -0600 >=20 > --=3D-=3D-=3D > Content-Transfer-Encoding: quoted-printable >=20 > >>>>> "Jean-Baptiste" =3D3D=3D3D Jean-Baptiste Cazier <Jean-Baptiste.cazi= er@d=3D > ecode.is> writes: >=20 > Jean-Baptiste> S=3DE6l ! Is there a way to "turn-off" lines without > Jean-Baptiste> removing the data ? My goal is to hide some lines > Jean-Baptiste> in a plot wihtout losing the data so I can show it > Jean-Baptiste> again later. I can do # Hide the line > Jean-Baptiste> x=3D3Dline.get_xdata() y=3D3Dline.get_ydata() > Jean-Baptiste> line.set_data([],[]) >=20 > This can be done very easily (for any artist) with a minor > modification of artist.py. The base class forewards all drawing to > the derived classes so no other changes are required. Just replace > artist.py with the attached file below and then you can do: >=20 > from matplotlib.matlab import * >=20 > x =3D3D arange(0.0, 1.0, 0.05) > l1, l2 =3D3D plot(x, sin(2*pi*x), x, sin(4*pi*x)) > l1.set_visible(False) > show() >=20 >=20 > --=3D-=3D-=3D > Content-Type: application/octet-stream > Content-Disposition: attachment; filename=3Dartist.py >=20 > from __future__ import division > import sys >=20 > from cbook import True, False, enumerate > from transforms import RWRef >=20 > class DPI(RWRef): > 'DPI as a read/write reference' > pass > =20 > =20 > class Artist: > """ > Abstract base class for someone who renders into a Figure >=20 > Public attributes > dpi : a DPI instance > bbox : a Bound2D instance in display coords > transform : a Transform instance > renderer : the last renderer used to draw, or None > """ >=20 > aname =3D 'Artist' > def __init__(self, dpi, bbox): =20 > self.renderer =3D None > self._lod =3D False > self.dpi =3D dpi > self.bbox =3D bbox > self._clipOn =3D True > self._alpha =3D 1.0 > self._visible =3D True > =20 > def get_alpha(self): > """ > Return the alpha value used for blending - not supported on > all backends > """ > return self._alpha >=20 > def get_visible(self, b): > "return the artist's visiblity" > return self._visible=20 >=20 > def get_clip_on(self): > 'Return whether artist uses clipping' > return self._clipOn >=20 > def set_clip_on(self, b): > 'Set whether artist is clipped to bbox' =20 > self._clipOn =3D b >=20 > def set_visible(self, b): > "set the artist's visiblity" > self._visible =3D b > =20 > def set_child_attr(self, attr, val): > """ > Set attribute attr for self, and all child artists > """ > setattr(self, attr, val) > for c in self.get_child_artists(): > c.set_child_attr(attr, val) >=20 >=20 > def get_child_artists(self): > 'Return all artists contained in self' > return [] >=20 > def get_window_extent(self, renderer=3DNone): > 'Return the window extent of the Artist as a Bound2D instance' > raise NotImplementedError('Derived must override') >=20 >=20 > def get_dpi(self): > """ > Get the DPI of the display > """ > return self._dpi >=20 >=20 > def draw(self, renderer=3DNone, *args, **kwargs): > 'Derived classes drawing method' > if not self._visible: return=20 > if renderer is None: renderer =3D self.renderer > if renderer is None: return > self.renderer =3D renderer > =20 > self._draw(renderer, *args, **kwargs) >=20 > def _draw(self, renderer, *args, **kwargs): > 'Derived classes drawing method' > raise NotImplementedError, 'Derived must override' >=20 > def set_alpha(self, alpha): > """ > Set the alpha value used for blending - not supported on > all backends > """ > self._alpha =3D alpha >=20 > def set_lod(self, on): > """ > Set Level of Detail on or off. If on, the artists may examine > things like the pixel width of the axes and draw a subset of > their contents accordingly > """ > self._lod =3D on >=20 > =20 >=20 >=20 >=20 > --=3D-=3D-=3D >=20 >=20 > You'll still have a little function call overhead, but it should be > *significantly faster* than your current approach. >=20 > JDH >=20 > --=3D-=3D-=3D-- >=20 >=20 >=20 > --__--__-- >=20 > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >=20 >=20 > End of Matplotlib-users Digest --=20 ----------------------------- Jea...@de... Department of Statistics deCODE genetics Sturlugata,8 570 2993 101 Reykjav=EDk |