I tried it both ways and got the same results.

In my cell where I pasted the entire script, I have the %matplotlib
notebook at the top of that same cell and the script runs correctly. It
also runs correctly if I move the  %matplotlib notebook into a cell by
itself.

The only time the script does not work correctly is with %run. It appears
that my plt.cla() call (which I need for my particular animation) in each
frame is being ignored (or not working correctly) in this case, but it
works fine in the cell that contains the entire script.

On 15 January 2018 at 09:52, Thomas Kluyver <[email protected]> wrote:

> Are you using the two magics in one cell, or over two cells? Some of the
> effects of the %matplotlib magic may not take effect until the next cell.
>
> On 15 January 2018 at 13:31, <[email protected]> wrote:
>
>> I have a bit of a strange issue.
>>
>> I have a Matplotlib FuncAnimation that runs correctly in a standalone
>> script in IPython. It also runs correctly if I copy the entire script into
>> a notebook cell and run it after the following magic
>>
>>     %matplotlib notebook
>>
>> However, if I use the following two magics
>>
>>     %matplotlib notebook
>>     %run myscript.py
>>
>> the animation does not run correctly.
>>
>> I'd prefer to use $run so that I can pass command line arguments to the
>> script.
>>
>> Any ideas why using the two magics approach would not work, but pasting
>> the entire script into a cell does?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Project Jupyter" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/jupyter/26b490aa-3c91-4ec9-b546-4f785f4cab0f%40googlegroups.com
>> <https://groups.google.com/d/msgid/jupyter/26b490aa-3c91-4ec9-b546-4f785f4cab0f%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Project Jupyter" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/jupyter/xTUys4tzHXU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/jupyter/CAOvn4qg4HKdernVrhS3R3cQct7TQTj2iuhZewwSJ6f6YLDEUSg%40mail.
> gmail.com
> <https://groups.google.com/d/msgid/jupyter/CAOvn4qg4HKdernVrhS3R3cQct7TQTj2iuhZewwSJ6f6YLDEUSg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/CA%2Bsg3DWVNsPP2sGXMd2fVFpznYr08NhSXH0qQht-0gSBnkXEfA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to