On Thu, Jun 19, 2008 at 8:58 AM, Alan G Isaac <[EMAIL PROTECTED]> wrote:
> On Thu, 19 Jun 2008, Scott Sinclair apparently wrote:
>> canvas = FigureCanvas(fig)
>
> What is the relationship between a figure and a canvas?

The Figure is the top level matplotlib artist container that contains
all the other matplotlib.artist.Artist instances (Axes, Line2D,
etc..).  Artists don't know anything about output formats (GDK, PS,
SVG) but they do know about renderers
(matplotlib.backend_bases.RendererBase) which have methods like
draw_line, draw_rectangle, and draw_text.  The renderer subclasses
know the various output languages like postscript or svg.  The canvas
is the target of the drawing by the renderer, and the canvas puts all
the pieces together.  The canvas contains a renderer that knows how to
draw on the canvas, and it also contains the figure instance to be
drawn.  The canvas calls

  fig.draw(renderer)

and then the figure instance in turn calls

  self.figurePatch.draw(renderer)

and then the figurePatch, a matplotlib.patches.Rectangle instance, calls

  renderer.draw_rectangle(graphicscontext, 25, 40)

So the renderer doesn't know anything about the matplotlib artist
Rectangle, but the Rectangle knows how to tell the renderer to draw
itself.  This design decouples the functionality to make it possible
to change the artists w/o affecting the renderers, so the drawing API
is not affected by the matplotlib artist classes.  This is covered
somewhat in Chapter 10 of the user's guide
http://matplotlib.sourceforge.net/users_guide_0.98.0.pdf

JDH

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to