Quantcast

IPy Notebook: Continue plotting in the same figure from another cell

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

IPy Notebook: Continue plotting in the same figure from another cell

Norfeldt
This is properly a trivial question and due to my lack of experience with matplotlib (come from a MATLAB environment) :

Here is an illustration of my question:

--Cell 1----------------------------------
fig = figure(1)
fig.clf()

count, bars, ignored = hist(very_very_big_population, 40, normed=True)
plot(bars, bell_curve_data(bars), color='r')
-------------------------------------------

-- Markup cell ----------------------
Some text explaining what I want to do next or other stuff.
-------------------------------------------

--Cell 2--------------------------------
fig # continue plotting on the previous figure

plot(bars, some_other_data, color='g')
------------------------------------------

However I can't seem to continue plotting on the same figure and have to run the hist and plot again - which takes time since it is really a big big population...

How do I continue plotting on the figure from the previous cell (Cell 1) ________________________?


BONUS QUESTION:

While typing this I quickly started thinking if it is possible to copy the figure with plot ____________________?
So say I want to plot something in Cell 2 on the the figure from Cell 1 but still want to be able to get a "clean" (without the Cell 2 plotting) Cell 1 figure in Cell 3 and do some different plotting on this.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: IPy Notebook: Continue plotting in the same figure from another cell

Matthias Bussonnier

Short from my phone.

There is an autoclose option on profile/command line see --help-all
Set it to false.

Or the preferable way. Use matplotlib OO interface:

Fig,ax =subplots(1,1)
ax.plot(...)

Markdown

ax.dosomethingelse(...)

Which is the real way of using matplotlib without pylab magic. It is much more powerfull.
--
Matthias

Le 10 janv. 2013 09:09, "Norfeldt" <[hidden email]> a écrit :
This is properly a trivial question and due to my lack of experience with
matplotlib (come from a MATLAB environment) :

Here is an illustration of my question:

--Cell 1----------------------------------
fig = figure(1)
fig.clf()

count, bars, ignored = hist(very_very_big_population, 40, normed=True)
plot(bars, bell_curve_data(bars), color='r')
-------------------------------------------

-- Markup cell ----------------------
Some text explaining what I want to do next or other stuff.
-------------------------------------------

--Cell 2--------------------------------
fig # continue plotting on the previous figure

plot(bars, some_other_data, color='g')
------------------------------------------

However I can't seem to continue plotting on the same figure and have to run
the hist and plot again - which takes time since it is really a big big
population...

How do I continue plotting on the figure from the previous cell (Cell 1)
________________________?


BONUS QUESTION:

While typing this I quickly started thinking if it is possible to copy the
figure with plot ____________________?
So say I want to plot something in Cell 2 on the the figure from Cell 1 but
still want to be able to get a "clean" (without the Cell 2 plotting) Cell 1
figure in Cell 3 and do some different plotting on this.



--
View this message in context: http://python.6.n6.nabble.com/IPy-Notebook-Continue-plotting-in-the-same-figure-from-another-cell-tp5001910.html
Sent from the IPython - User mailing list archive at Nabble.com.
_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user

_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: IPy Notebook: Continue plotting in the same figure from another cell

Chao
I think if you're using notebook with inline mode, maybe currently it doesn't suport interactive plotting.

if you can succeed with the same code in ipython --pylab without notebook, then it's what as
I indicate. I think ipython --pylab will enable you to do what you want even without using OO
interface.

chao


On Thu, Jan 10, 2013 at 9:25 AM, Matthias Bussonnier <[hidden email]> wrote:

Short from my phone.

There is an autoclose option on profile/command line see --help-all
Set it to false.

Or the preferable way. Use matplotlib OO interface:

Fig,ax =subplots(1,1)
ax.plot(...)

Markdown

ax.dosomethingelse(...)

Which is the real way of using matplotlib without pylab magic. It is much more powerfull.
--
Matthias

Le 10 janv. 2013 09:09, "Norfeldt" <[hidden email]> a écrit :

This is properly a trivial question and due to my lack of experience with
matplotlib (come from a MATLAB environment) :

Here is an illustration of my question:

--Cell 1----------------------------------
fig = figure(1)
fig.clf()

count, bars, ignored = hist(very_very_big_population, 40, normed=True)
plot(bars, bell_curve_data(bars), color='r')
-------------------------------------------

-- Markup cell ----------------------
Some text explaining what I want to do next or other stuff.
-------------------------------------------

--Cell 2--------------------------------
fig # continue plotting on the previous figure

plot(bars, some_other_data, color='g')
------------------------------------------

However I can't seem to continue plotting on the same figure and have to run
the hist and plot again - which takes time since it is really a big big
population...

How do I continue plotting on the figure from the previous cell (Cell 1)
________________________?


BONUS QUESTION:

While typing this I quickly started thinking if it is possible to copy the
figure with plot ____________________?
So say I want to plot something in Cell 2 on the the figure from Cell 1 but
still want to be able to get a "clean" (without the Cell 2 plotting) Cell 1
figure in Cell 3 and do some different plotting on this.



--
View this message in context: http://python.6.n6.nabble.com/IPy-Notebook-Continue-plotting-in-the-same-figure-from-another-cell-tp5001910.html
Sent from the IPython - User mailing list archive at Nabble.com.
_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user

_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user




--
***********************************************************************************
Chao YUE
Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
UMR 1572 CEA-CNRS-UVSQ
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex
Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
************************************************************************************

_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: IPy Notebook: Continue plotting in the same figure from another cell

Chao
and

ychao@lsce3139:~$ ipython notebook --pylab

will enable you to do in the first cell:

plot(np.arange(10))

and the second:
xlabel('I am xlabel')

after the second, the figure will be updated.

Chao

On Thu, Jan 10, 2013 at 9:45 AM, Chao YUE <[hidden email]> wrote:
I think if you're using notebook with inline mode, maybe currently it doesn't suport interactive plotting.

if you can succeed with the same code in ipython --pylab without notebook, then it's what as
I indicate. I think ipython --pylab will enable you to do what you want even without using OO
interface.

chao



On Thu, Jan 10, 2013 at 9:25 AM, Matthias Bussonnier <[hidden email]> wrote:

Short from my phone.

There is an autoclose option on profile/command line see --help-all
Set it to false.

Or the preferable way. Use matplotlib OO interface:

Fig,ax =subplots(1,1)
ax.plot(...)

Markdown

ax.dosomethingelse(...)

Which is the real way of using matplotlib without pylab magic. It is much more powerfull.
--
Matthias

Le 10 janv. 2013 09:09, "Norfeldt" <[hidden email]> a écrit :

This is properly a trivial question and due to my lack of experience with
matplotlib (come from a MATLAB environment) :

Here is an illustration of my question:

--Cell 1----------------------------------
fig = figure(1)
fig.clf()

count, bars, ignored = hist(very_very_big_population, 40, normed=True)
plot(bars, bell_curve_data(bars), color='r')
-------------------------------------------

-- Markup cell ----------------------
Some text explaining what I want to do next or other stuff.
-------------------------------------------

--Cell 2--------------------------------
fig # continue plotting on the previous figure

plot(bars, some_other_data, color='g')
------------------------------------------

However I can't seem to continue plotting on the same figure and have to run
the hist and plot again - which takes time since it is really a big big
population...

How do I continue plotting on the figure from the previous cell (Cell 1)
________________________?


BONUS QUESTION:

While typing this I quickly started thinking if it is possible to copy the
figure with plot ____________________?
So say I want to plot something in Cell 2 on the the figure from Cell 1 but
still want to be able to get a "clean" (without the Cell 2 plotting) Cell 1
figure in Cell 3 and do some different plotting on this.



--
View this message in context: http://python.6.n6.nabble.com/IPy-Notebook-Continue-plotting-in-the-same-figure-from-another-cell-tp5001910.html
Sent from the IPython - User mailing list archive at Nabble.com.
_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user

_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user




--
***********************************************************************************
Chao YUE
Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
UMR 1572 CEA-CNRS-UVSQ
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex
Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
************************************************************************************



--
***********************************************************************************
Chao YUE
Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
UMR 1572 CEA-CNRS-UVSQ
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex
Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
************************************************************************************

_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: IPy Notebook: Continue plotting in the same figure from another cell

Norfeldt
Thank you both for your helpful answer :)

I was using the IPy inline (such neat and useful feature)

Matthias:
The autoclose must do more than just closing the figure - it must do fig.clf()
The OO way is useful and reminds me that I always forget that it is the axes that contain the plot goodies and not the figure.
(to me it would be more obvious to call figure -> window and axes -> plot - but that's just my world)

I will try to disable the autoclose next time..

Chao:
I like your way of doing it - but then I would need to know the magic command for plotting inline




On Thu, Jan 10, 2013 at 9:48 AM, Chao [via Python] <[hidden email]> wrote:
and

ychao@lsce3139:~$ ipython notebook --pylab

will enable you to do in the first cell:

plot(np.arange(10))

and the second:
xlabel('I am xlabel')

after the second, the figure will be updated.

Chao


On Thu, Jan 10, 2013 at 9:45 AM, Chao YUE <[hidden email]> wrote:
I think if you're using notebook with inline mode, maybe currently it doesn't suport interactive plotting.

if you can succeed with the same code in ipython --pylab without notebook, then it's what as
I indicate. I think ipython --pylab will enable you to do what you want even without using OO
interface.

chao



On Thu, Jan 10, 2013 at 9:25 AM, Matthias Bussonnier <[hidden email]> wrote:

Short from my phone.

There is an autoclose option on profile/command line see --help-all
Set it to false.

Or the preferable way. Use matplotlib OO interface:

Fig,ax =subplots(1,1)
ax.plot(...)

Markdown

ax.dosomethingelse(...)

Which is the real way of using matplotlib without pylab magic. It is much more powerfull.
--
Matthias

Le 10 janv. 2013 09:09, "Norfeldt" <[hidden email]> a écrit :

This is properly a trivial question and due to my lack of experience with
matplotlib (come from a MATLAB environment) :

Here is an illustration of my question:

--Cell 1----------------------------------
fig = figure(1)
fig.clf()

count, bars, ignored = hist(very_very_big_population, 40, normed=True)
plot(bars, bell_curve_data(bars), color='r')
-------------------------------------------

-- Markup cell ----------------------
Some text explaining what I want to do next or other stuff.
-------------------------------------------

--Cell 2--------------------------------
fig # continue plotting on the previous figure

plot(bars, some_other_data, color='g')
------------------------------------------

However I can't seem to continue plotting on the same figure and have to run
the hist and plot again - which takes time since it is really a big big
population...

How do I continue plotting on the figure from the previous cell (Cell 1)
________________________?


BONUS QUESTION:

While typing this I quickly started thinking if it is possible to copy the
figure with plot ____________________?
So say I want to plot something in Cell 2 on the the figure from Cell 1 but
still want to be able to get a "clean" (without the Cell 2 plotting) Cell 1
figure in Cell 3 and do some different plotting on this.



--
View this message in context: http://python.6.n6.nabble.com/IPy-Notebook-Continue-plotting-in-the-same-figure-from-another-cell-tp5001910.html
Sent from the IPython - User mailing list archive at Nabble.com.
_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user

_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user




--
***********************************************************************************
Chao YUE
Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
UMR 1572 CEA-CNRS-UVSQ
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex
Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
************************************************************************************



--
***********************************************************************************
Chao YUE
Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
UMR 1572 CEA-CNRS-UVSQ
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex
Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
************************************************************************************

_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user



If you reply to this email, your message will be added to the discussion below:
http://python.6.n6.nabble.com/IPy-Notebook-Continue-plotting-in-the-same-figure-from-another-cell-tp5001910p5001916.html
To unsubscribe from IPy Notebook: Continue plotting in the same figure from another cell, click here.
NAML

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: IPy Notebook: Continue plotting in the same figure from another cell

Matthias Bussonnier

Le 10 janv. 2013 à 14:16, Norfeldt a écrit :

> Thank you both for your helpful answer :)
>
> I was using the IPy inline (such neat and useful feature)
>
> Matthias:
> The autoclose must do more than just closing the figure - it must do fig.clf()
> The OO way is useful and reminds me that I always forget that it is the axes that contain the plot goodies and not the figure.
> (to me it would be more obvious to call figure -> window and axes -> plot - but that's just my world)
>
> I will try to disable the autoclose next time..
>
> Chao:
> I like your way of doing it - but then I would need to know the magic command for plotting inline

I don't remember since when, but you can toggle between inline backend with
%pylab [gui]
%pylab inline
--
Matthias

_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: IPy Notebook: Continue plotting in the same figure from another cell

Norfeldt
Okay so had the time to try out your suggestions and unfortunately they did not work for me.



Both 104, 105, 106 have been executed. I can't seem to display 0x3a82cd0

I need to use -inline since I'm doing remote computing and because it is suppose to serve as a tutorial in a blog post.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: IPy Notebook: Continue plotting in the same figure from another cell

Juergen Hasch
For me,
using "fig" to plot the figure works, i.e.:

        fig,ax = subplots(1,1)
        ax.plot(sin(range(0,10)))

...first inline figure...

        ax.plot(cos(range(0,10)))
        fig

...appended inline figure...


Am 12.01.2013 13:07, schrieb Norfeldt:

> Okay so had the time to try out your suggestions and unfortunately they did
> not work for me.
>
> <http://python.6.n6.nabble.com/file/n5002158/interactive_inline_plotting.png>
>
> Both 104, 105, 106 have been executed. I can't seem to display 0x3a82cd0
>
> I need to use -inline since I'm doing remote computing and because it is
> suppose to serve as a tutorial in a blog post.
>
>
>
> --
> View this message in context: http://python.6.n6.nabble.com/IPy-Notebook-Continue-plotting-in-the-same-figure-from-another-cell-tp5001910p5002158.html
> Sent from the IPython - User mailing list archive at Nabble.com.
> _______________________________________________
> IPython-User mailing list
> [hidden email]
> http://mail.scipy.org/mailman/listinfo/ipython-user
>

_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: IPy Notebook: Continue plotting in the same figure from another cell

Norfeldt
THANK you Juergen for your quick answer! It totally did the trick



I'm not sure I understand the logic in why fig has to be called in order to display the figure - but guessing that it has something to do with the inline syntax
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: IPy Notebook: Continue plotting in the same figure from another cell

Chao
yes. It also works for me, a very useful tip.

Chao

On Sat, Jan 12, 2013 at 1:41 PM, Norfeldt <[hidden email]> wrote:
THANK you Juergen for your quick answer! It totally did the trick

<http://python.6.n6.nabble.com/file/n5002165/inline_programming.png>

I'm not sure I understand the logic in why fig has to be called in order to
display the figure - but guessing that it has something to do with the
inline syntax



--
View this message in context: http://python.6.n6.nabble.com/IPy-Notebook-Continue-plotting-in-the-same-figure-from-another-cell-tp5001910p5002165.html
Sent from the IPython - User mailing list archive at Nabble.com.
_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user



--
***********************************************************************************
Chao YUE
Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
UMR 1572 CEA-CNRS-UVSQ
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex
Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
************************************************************************************

_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Loading...