In another thread I said, 

> Imo, Leo should aim to provide all the rendering capabilities of the 
IPython Qt shell and the Jupyter notebooks.

In some sense, Leo's --ipython command-line operation already gives Leo 
these capabilities. When I enter (in IPython's Qt console) the example in 
the qtconsole docs <http://jupyter.org/qtconsole/stable/#inline-graphics>, 
I see pretty much what is shown, except that the graphics appear as a 
separate pane on both Ubuntu and Windows 10.

The big question is, *how much extra work will it take to make this work in 
Leo itself ?*  Hmm.  Let's put the code in the body pane...

The following works, but the print gets swallowed by the IPython console:

    from scipy.special import jn
    print(jn)

*Note*: I am using the Anaconda distribution.

g.es(jn) shows:

    <ufunc 'jv'>

which presumably is some kind of IPython/scipy magic.

Going on, this throws a NameError. linespace is not defined:

    x = linspace(0,4*pi)

Oh good, the exception (stderr) *does* show up in the console.

Presumably, IPython defines linespace somehow. Googling `scipy linspace` 
yields entries for `numpy linspace'.  This works:

    from scipy.special import jn
    from numpy import linspace, pi
    x = linspace(0,4*pi)
    g.es(x)

x is array of numbers, just like what is shown in the IPython Qt console 
for x. 

Doh, querying `linespace` in the Qt console shows:

    <function numpy.core.function_base.linspace>

This is better than googling :-)  Querying `plot` in the Qt console shows:

    <function matplotlib.pyplot.plot>

Drum roll please, what happens when we execute?:

    from scipy.special import jn
    from matplotlib.pyplot import plot
    from numpy import linspace, pi
    x = linspace(0,4*pi)
    for i in range(6):
        plot(x, jn(i,x))

Hurray! This puts up a matplotlib plot, identical to the plot created from 
the IPython Qt console!


*Summary*
Leo can *already* do everything (in Leo's body pane) that IPython can do in 
the IPython Qt console.  A few extra imports are needed, but that's so easy 
to do in Leo!  Write the import once and forget about it.

This is an important realization for me.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" 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].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to