[IPython-dev] notebook plots via javascript

Bob McElrath bob+ipython at mcelrath.org
Fri Jun 8 11:49:21 EDT 2012

Zoltán Vörös [zvoros at gmail.com] wrote:
> I have the feeling that these goals are too ambitious. I think, there is a
> desire to keep plotting within the realm of matplotlib, but add some
> interactivity to it. 

Well I'll just say that IPython and matplotlib have quickly become my primary
computational tool.  So I would not simply call it an "exploratory" tool.  I
could already do exploratory computing with the (i)python command line.  The
notebook allows me to save, repeat/reproduce, and communicate a computation.  In
particular it allows me to record how I produced the final version of a plot.

I have been cursing the capabilities, failures, and crashes of Maple and
Mathematica for more than a decade now.  One of the major things where both of
those packages fall down is plotting.  For years I have been exporting data to
flat files and importing it into xmgrace, because the quality of their plots was
so poor.  Matplotlib is substantially better than any of the above.  So, I will
be producing my plots using it from now on.  (And I will undoubtedly be
exporting data from Maple into an IPython notebook for plotting purposes soon)
I see the IPython notebook as a replacement for Maple, for me.

The interface for creating matplotlib plots is no worse than Gnuplot, Maple, or
Mathematica, in terms of having to construct the plot using a script.  There is
a lot of room for improvement there.  What I would like is to eventually have a
GUI-like way to do simple manipulation of plots, along the lines of xmgrace and

Anyway, it's a long term goal.  For now I'm just going to try to get a
reasonable vector-based rather than rasterized output for the notebook.  This is
required so that different screen/browser sizes, font sizes look reasonable.

> But I just fail to see why plots should be resizable, and why plots should be
> able to emit python code for tracking the changes. 

Personally I do not find zooming/panning terribly useful.  If I need to
zoom/pan, it always means either
1. I will have to re-plot to pan anyway
2. I will have to recompute at higher resolution so the zoom/pan is smooth
About the only thing I do with the gtk matplotlib GUI that is useful is change
the margins.

The things that are easier to do with an interactive plot are logged axes, tick
mark spacing, line type/color, axis labels, legend, title, grid, 3d rotation.
None of which you can do with the matplotlib gui.

> I have a javascript backend now that produces stand-alone javascript, and
> allows for grid toggling, and coordinate reporting + cross-hairs. 

That would be great!  Coordinate reporting is also one thing the GUI is useful

Cheers, Bob McElrath

"The individual has always had to struggle to keep from being overwhelmed by
the tribe.  If you try it, you will be lonely often, and sometimes frightened.
But no price is too high to pay for the privilege of owning yourself." 
    -- Friedrich Nietzsche

More information about the IPython-dev mailing list