pyplot <http://matplotlib.org/users/pyplot_tutorial.html> is the python
interface to matplotlib <http://matplotlib.org/>. Imo, better pyplot
support will give Leo most of the capabilities of the Jupyter
<http://jupyter.org/> notebook.
This project came about as the result of a thought experiment, namely using
Jupyter as a prototype for Leo as a web app. But I soon realized it would
be a whole lot easier to add pyplot support to Leo than to add all of Leo
to Jupyter ;-)
Here is the checkin log:
QQQQQ
Added preliminary support for @pyplot drawing in viewrendered plugin:
- @pyplot nodes are assumed to contain pyplot scripts.
The update code automagically imports the following, so scripts don't
have to:
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.animation as animation
- Added leo/plugins/pyplot_backend.py.
At present, the backend draws to separate Qt dialogs.
We would prefer that all figures get drawn in the VR pane.
More work is coming.
QQQQQ
Here is an example: The headline is @pyplot basic_example, the body is:
# http://matplotlib.org/1.5.1/examples/animation/basic_example.html
if 0:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
fig2 = plt.figure()
x = np.arange(-9, 10)
y = np.arange(-9, 10).reshape(-1, 1)
base = np.hypot(x, y)
ims = []
for add in np.arange(15):
ims.append((plt.pcolor(x, y,
base + add,
norm=plt.Normalize(0, 30)),))
animation.ArtistAnimation(fig2, ims,
interval=50,
repeat_delay=3000,
blit=True)
if 0:
plt.ion()
# sets interactive mode. Prevents this message:
# QCoreApplication::exec: The event loop is already running
plt.show()
*Notes*:
1. The commented-out code is essential if you ran the script with Ctrl-B.
But it's not necessary if you view the the node with the viewrendered
plugin.
2. At present, the vr plugin executes the script when you select the node.
It does *not* re-render the node as text changes. That would result in
lots of syntax errors. To re-render the node, execute the vr-update command.
3. The file leo/plugins/pyplot_backend.py is *not* a real plugin. It
provides a pyplot backend to the vr plugin. At present, it works *only*
with PyQt4. Eventually, it should work with PyQt5. Perhaps more
importantly, the backend should embed pyplot figures in the VR pane.
That's next. It may be a bit tricky.
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.