From: Jochen V. <vo...@se...> - 2004-11-02 19:37:37
|
Hello, why is figure derived from the Artist class? This causes some special casing (figure is the only artist where artist.figure does not point to the figure). The the figure actually used as an Artist somewhere? What would break if it would not be derived from Artist? I tried the patch =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D diff -u -r1.5 figure.py --- figure.py 21 Oct 2004 19:57:50 -0000 1.5 +++ figure.py 2 Nov 2004 19:35:03 -0000 @@ -13,7 +13,7 @@ =20 =20 =20 -class Figure(Artist): +class Figure: =20 def __init__(self, figsize =3D None, # defaults to rc figure.figsize @@ -27,7 +27,7 @@ paper size is a w,h tuple in inches DPI is dots per inch=20 """ - Artist.__init__(self) + #Artist.__init__(self) #self.set_figure(self) =20 if figsize is None : figsize =3D rcParams['figure.figsize'] =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D and everything still seems to work. Maybe a figure should be just something which uses artists to do its work instead of being one itself. What do you think? Jochen --=20 http://seehuhn.de/ |
From: John H. <jdh...@ac...> - 2004-11-03 22:24:05
|
>>>>> "Jochen" == Jochen Voss <vo...@se...> writes: Jochen> Hello, why is figure derived from the Artist class? This Jochen> causes some special casing (figure is the only artist Jochen> where artist.figure does not point to the figure). Jochen> The the figure actually used as an Artist somewhere? What Jochen> would break if it would not be derived from Artist? In a couple of places - in the call to set_transform in Figure._set_artist_props and when FigureCanvas calls figure.draw(renderer). One could write a figure class that was not derived form Artist, but I don't really see the benefit of changing it. The Artist hierarchy are basically all the things that implement draw(renderer). Of course in a dynamically typed language one doesn't need to derive from Artist to implement draw(renderer), but it seems conceptually cleaner to do so in this case -- plus I have already done the Artist hierarchy in graphviz and included it in the users guide :-) It might also break some code which is relying on the Artist methods, eg fig.get_transform (for people who want to add lines, text, etc in fig coords). I doubt there are many such people, but it is a possibility. Jochen> I tried the patch I didn't test this - did it pass backend_driver? JDH |
From: Jochen V. <vo...@se...> - 2004-11-04 12:05:31
|
Hello John, On Wed, Nov 03, 2004 at 04:14:55PM -0600, John Hunter wrote: > >>>>> "Jochen" =3D=3D Jochen Voss <vo...@se...> writes: > Jochen> The the figure actually used as an Artist somewhere? What > Jochen> would break if it would not be derived from Artist? >=20 > In a couple of places - in the call to set_transform in > Figure._set_artist_props ... I see. > ... and when FigureCanvas calls figure.draw(renderer). This is different, isn't it? FigureCanvas calls figure.draw(renderer) only calls this with proper figures and never with other Artists. So inheritance is not used here. > ... The Artist hierarchy are basically all the things that implement > draw(renderer). ... Ok! This makes it look ok to me. I am just in the process of understanding how the internals of matplotlib work. > Jochen> I tried the patch >=20 > I didn't test this - did it pass backend_driver? It seemed to work fine, but maybe I just didn't spot the problems. Now I can't really understand how the set_transform calls in Figure._set_artist_props could possible have worked. Thank you very much, Jochen --=20 http://seehuhn.de/ |
From: John H. <jdh...@ac...> - 2004-11-04 15:28:07
|
>>>>> "Jochen" == Jochen Voss <vo...@se...> writes: Jochen> It seemed to work fine, but maybe I just didn't spot the Jochen> problems. Now I can't really understand how the Jochen> set_transform calls in Figure._set_artist_props could Jochen> possible have worked. Basically, noone ever uses the figure transform. One could, if you want to draw in figure coords (0,0 is lower left of figure, 1,1 is upper right, it's just that this doesn't happen in real life very often. I doubt any of the backend_driver scripts utilize this. JDH |