Skip to content

Plotting with Matplotlib

Jean-Luc Stevens edited this page Jul 7, 2017 · 2 revisions

Missing material:

Jim's comment in #1658:

What I would think would be useful to add to this notebook is a discussion of how the matplotlib backend works, in comparison to the Bokeh or plotly backends, and what the pros and cons are. Basically, for static output the matplotlib backend renders each the plot (or each plot, for a HoloMap) to a PNG, and then HoloViews generates JavaScript that provides widgets to select between these pre-rendered PNGs. This process is very different from the Bokeh or Plotly backends, which generate JavaScript/HTML directly that contains specific glyphs corresponding to the data in the plot.

The matplotlib backend approach has the advantage that the output size is largely independent of the amount of data involved, and that the resulting output requires less JavaScript and is overall simpler once rendered, which also makes it more future-proof as a saved plot with widgets.

The bokeh/plotly approach has the advantage that these backends provide interactivity within the plot, even in a static HTML/JS output, which opens up a wide range of possible user-visible functionality such as zooming in to see detail, dynamically re-rendering plots on zooming with Datashader, and so on . At least in principle, for small numbers of datapoints spread across many frames of a HoloMap, the Bokeh/Plotly approach could have much smaller file sizes, but I haven't done benchmarking to see where the crossover point would be.