Demo of mpld3

This notebook gives a brief overview of mpld3, a package which allows seamless visualization of matplotlib plots using HTML, Javascript, and the D3js package.

One of the nicest parts of the IPython notebook is the ability to embed figures inline with code. For example, we can quickly create a scatter plot as so:

A weakness quickly becomes clear, however: the embedded figure is a simple static PNG image.

This is where mpld3 comes in. Using the simple mpld3.display() command, we can create a fully interactive visualization of the same plot:

Notice that as you hover over the plot, a toolbar appears in the lower left. This has tools to enable panning and zooming, and a button to reset the view once you've explored the plot.

If you'd like to use mpld3 by default for every figure you generate, you can call the following command:

Other Plot Types

Nearly any type of plot matplotlib can do, mpld3 can visualize as well. Below are some examples:

A Histogram

Line Plots with Legend