Scientific Plotting in Python

of 12 /12
Scientific Plotting in Python Jack Parmer CEO, Plotly BS Engineering Physics

Embed Size (px)


Matplotlib has wonderfully served the Python community as the cornerstone of scientific graphics. Recently, many additional Python plotting options have surfaced, aimed to make it easier to create graphics that are interactive and web-publishable. These slides outline some of the new options with links to easy-to-follow, IPython notebooks.

Transcript of Scientific Plotting in Python

Page 1: Scientific Plotting in Python

Scientific Plotting in Python

Jack ParmerCEO, PlotlyBS Engineering Physics

Page 2: Scientific Plotting in Python

Developed over 10+ years.

Cornerstone of scientific graphing in Python.


Page 3: Scientific Plotting in Python

New Expectationsfor Scientific Graphics● Interactive

● Shareable on the Web

● Data is accessible

● Informed aesthetics

Page 4: Scientific Plotting in Python

Technology RoadblockMatplotlib generates raster images.

● Not interactive

● Data is lost from graph

● No free anti-aliasing or fonts from browser technology

Page 5: Scientific Plotting in Python

New Project - mplexporterExtract matplotlib “graph DNA” to a universal JSON format, that anyone can read.

IPython Notebook:

GitHub Repo:


Page 6: Scientific Plotting in Python

mplexport Improves Data Liquidity

x: [ 10.0, 20.0, 30.0 ]

y: [ 100.0, 200.0, 300.0 ]

Data is sent to matplotlib figure.

A matplotlib figure object.

Extract figure data and layout with mplexporter.

Data can be reused for a different purpose.

Goal is to make data transfer bidirectional - Data can be put in *and* taken out of figures.

Plans to expand Matplotlib so that all figure objects include and expose their data.

Page 7: Scientific Plotting in Python

SVG and Web Graphics are IncredibleSeveral projects are leveraging rich webgraphics technology for plotting with Python

● mpld3 (Using SVG / d3.js)●

● Plotly (Using SVG / d3.js)●

● Bokeh (Using HTML5 Canvas)●

Page 8: Scientific Plotting in Python

SVG and Web Graphics are InteractiveUsing JavaScript, scientific figures rendered with Python can have interactive elements.

Zoom, pan, hover...

Page 9: Scientific Plotting in Python

Aesthetic Layering for MatplotlibSeveral projects work with Matplotlib to improve its default styling, without using web graphics technology (SVG or Canvas).

● prettyplotlib●

● Seaborn● http://www.stanford.


Page 10: Scientific Plotting in Python



Page 11: Scientific Plotting in Python

Sharing Scientific Plots on the WebPlotly syncs graphs and data to its cloud for free with its Python API.

Each graph is given a unique URL

Graphs are always kept with their original data.

fig1 = plt.figure()

x = np.arange(0,1.0,0.01)

y1 = np.sin(2*np.pi*x)

y2 = np.cos(4*np.pi*x)

ax = fig1.add_subplot(111)

ax.plot(x, y1, 'b--',


ax.plot(x, y2, 'ro',


ax.set_title("It's a Sign")



fig_to_plotly(fig1, \

plotly_username, \

plotly_api_key, \