Create plots in functions, plot later

Hello,

i try to write a module which evaluates various Data, and occasionally
creates a plot, which is returned to the user. At the discretion of the
user, he should be able to show selected plots. This is an example
module with two approaches for this problem:

···

-----------------
import pylab
import matplotlib

def makeplot1():
    pylab.ioff()
    fig = pylab.figure()
    spl1 = fig.add_subplot(211)
    spl2 = fig.add_subplot(212)
    spl1.plot([1,4,9,16])
    spl2.plot([1,3,5,7])
    pylab.ion()
    return fig

def makeplot2():
    fig = matplotlib.figure.Figure()
    spl1 = fig.add_subplot(211)
    spl2 = fig.add_subplot(212)
    spl1.plot([1,4,9,16])
    spl2.plot([1,3,5,7])
    return fig
----------------------

The user fires up ipython and imports my module:
ipython -pylab

import plotgen

After analysizing various data, he wants to look at a particular plot:

fig = plotgen.makeplot1()

Now can one make pop up this plot? I tried to make this figure current:

figure(fig.number)

but nothing to see. Then:

draw()
ion()

Only show() works, but this pops up all figures defined, and this can be
a large number of figures if makeplot1() has been called often, or I
have many figures. I only want to see this particular figure.

So next try with the object oriented interface:

fig = plotgen.makeplot2()
figure(fig.number)

AttributeError: Figure instance has no attribute 'number'

Ok, this does not work. In a cookbook i saw that one needs something
like "canvas = FigureCanvasAgg(fig)". But i cannot use it: As writer of
module "plotgen" i dont know what backend (Agg) is used by the user. And
the user simply uses "ipython -pylab" and should not care about the
backend.

Whats the correct solution for my problem?

Best Regards,

Roman