question about the figure class

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?

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
:slight_smile:

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.

    > I tried the patch

I didn't test this - did it pass backend_driver?

JDH

Hello John,

    > The the figure actually used as an Artist somewhere? What
    > 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 ...

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.

    > I tried the patch

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

···

On Wed, Nov 03, 2004 at 04:14:55PM -0600, John Hunter wrote:
--