[SciPy-user] gplt and xplt

David Grant david.grant at telus.net
Sat Aug 14 14:20:44 CDT 2004

Hi John,

John Hunter wrote:

>    David> In essence, can I build up two plots independently
>    David> at the same time? Then save them?
>Not a problem - here the matlab interface is not imported or used.
>The use of a separate Figure and FigureCanvas below results from
>trying to keep a clean separation from the frontend (Figure) and
>backend (Canvas)
>    from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
>    from matplotlib.figure import Figure
>    from matplotlib.numerix import rand
>    fig1 = Figure()
>    fig2 = Figure()
>    canvas1 = FigureCanvas(fig1)
>    canvas2 = FigureCanvas(fig2)
>    ax1 = fig1.add_subplot(111)
>    ax2 = fig2.add_axes([0.2, 0.2, 0.5, 0.5])  # a custom axes in fig2
>    ax1.plot([1,2,3])
>    ax2.scatter(rand(12), rand(12))
>    canvas1.print_figure('fig1.svg')  # switches to the svg backend
>    canvas1.print_figure('fig1.png')  # native agg saves png
>    canvas2.print_figure('fig2.eps')  # switches to the PS backend
>No call to show, etc....  The hardcopy is created upon executing this
>script.  Here I take advantage of the fact that most backends (agg in
>this case) can switch backends to render to PS/EPS/SVG/PNG depending
>on the extension.  You don't need to use the switching feature - you
>could have directly imported the SVG or PS backend canvas, but I
>included it for illustration.
>You use the same approach to create GUI canvases for embedding in an
>application, but the constructor args for the FigureCanvas vary
>somewhat from backend to backend.  And you would have to fire up your
>GUI mainloop and realize your windows, etc..
>Thanks for keeping me honest!  I'm working on a users guide and will
>include a section along these lines.
In the script above, how would you make the graphs show to the screen 
and not just save to a file?


David J. Grant

-------------- next part --------------
A non-text attachment was scrubbed...
Name: david.grant.vcf
Type: text/x-vcard
Size: 177 bytes
Desc: not available
Url : http://www.scipy.net/pipermail/scipy-user/attachments/20040814/a7fa85c1/david.grant.vcf

More information about the SciPy-user mailing list