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>
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
.