Well, not sure if that is supported, but I found a way !:
        [...]

        self.fig1 = Figure(figsize=(width, height), dpi=dpi)
        self.fig2 = Figure(figsize=(width, height), dpi=dpi)
        self.axes1 = self.fig1.add_subplot(223)
        self.axes2 = self.fig2.add_subplot(221)

        [...]
        self.axes2.plot([0,1])
(1)     self.axes2.set_figure(self.fig1)
(2)     self.fig1.add_axes(self.axes2)

Note that (1) and (2) are required in that order!
From the code above, if I show the fig1, then I see axes1 and axes2 on the 
figure....


Summary:
I created the axes2 independently of fig1

PS: I want to use my axes2 as an object to sent to my Qt widget (a blank 
figure/canvas)

--
Emmanuel



________________________________
 From: Eric Firing <efir...@hawaii.edu>
To: matplotlib-users@lists.sourceforge.net 
Sent: Sunday, April 1, 2012 1:36 PM
Subject: Re: [Matplotlib-users] assigning a plot object to a figure
 
On 03/30/2012 01:23 PM, Emmanuel Mayssat wrote:
> Hello all,
>
> I can create a figure
> and get the corresponding axes/plots
>
> for examples:
> 1/
> fig = Figure(figsize=(width, height), dpi=dpi)
> ax = gif.add_subplot(111)
>
> 2/
> fig, ax = plt.subplots()
>
> but I would like to create my plot independently from the figure and
> assign it to a figure
>
> I code I would like to do something like this
>
> my_ax = Axes(...)
> my_ax.plot(x,y)
>
>
> ax = my_ax
>
> or
>
> my_ax.set_figure(fig)
>
> How can I create the axes/plot object independently from the figure?

As far as I can see, you can't.  The figure is deeply embedded in the 
Axes object; that's why the figure is an argument in Axes.__init__().

> Better yet, how can I assign an axe to a figure?

I don't think you can.  It looks to me like Axes.set_figure should be 
clearly marked as a private method, not to be used except in 
Axes.__init__().

Short of a major refactoring of mpl, I think you will need to find some 
other way of accomplishing your ultimate aim.

Eric

> --
> Emmanuel

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to