Plotly


Plotly is a javascript library for data visualization. It is based on the famous d3.js library, and provides a python wrapper allowing to build stunning interactive charts directly from Python. Most of the gallery sections provide plotly examples, this post provides a few general tips.

⏱ Quick start

Matplotlib is the most famous python data visualization library. It is widely used and most of other viz libraries (like seaborn) are actually built on top of it.

Once installed, matplotlib must be imported, usually using import matplotlib.pyplot as plt. You can then use use the functions available in the plt object.

# library
import numpy as np
import matplotlib.pyplot as plt

# Create data
x=range(1,6)
y=[1,4,6,8,4]

# Area plot
plt.fill_between(x, y)
plt.show()

⏱ Saving a plotly chart

Once you've created a plotly chart you probably want to save it as a standalone html file in order to share it or embed it in another webpage.

This is the code allowing to save a plotly chart. You can read the full process here for instance.

fig.write_html("the/path/to/chart-name.html")

⏱ Embeding a plotly chart

Once the chart has been saved, you can embed it in a html document using:

<iframe
  src="the/path/to/chart-name.html"
  width="800"
  height="600"
  title="chart name"
  style="border:none">
</iframe>

Here is a glimpse of the plotly charts showcased in the gallery:

Contact

👋 This document is a work by Yan Holtz. Any feedback is highly encouraged. You can fill an issue on Github, drop me a message onTwitter, or send an email pasting yan.holtz.data with gmail.com.

Violin

Density

Histogram

Boxplot

Ridgeline

Scatterplot

Heatmap

Correlogram

Bubble

Connected Scatter

2D Density

Barplot

Spider / Radar

Wordcloud

Parallel

Lollipop

Circular Barplot

Treemap

Venn Diagram

Donut

Pie Chart

Dendrogram

Circular Packing

Line chart

Area chart

Stacked Area

Streamgraph

Timeseries with python

Timeseries

Map

Choropleth

Hexbin

Cartogram

Connection

Bubble

Chord Diagram

Network

Sankey

Arc Diagram

Edge Bundling

Colors

Interactivity

Animation with python

Animation

Cheat sheets

Caveats

3D