Plotly is a JS based plotting library with Python bindings (similar to bokeh). Plotly also has a portal online where users can upload their charts for public use.
pip instal plotly
import plotly
plotly.tools.set_credentials_file(username='', api_key='')
create your key here: https://plot.ly/settings/api
Plotly allows you to plot both
plot()
- returns a unique url and opens it new tabiplot()
- when using notebook to embed the plotoffline.plot
- creates a new html output pageoffline.iplot
- interactive while in a notebook
In [2]:
import plotly
In [3]:
plotly.tools.set_credentials_file(username='atmamani',
api_key='xxx')
In [4]:
import plotly.plotly as py
from plotly.graph_objs import *
trace0 = Scatter(
x=[1, 2, 3, 4],
y=[10, 15, 13, 17]
)
trace1 = Scatter(
x=[1, 2, 3, 4],
y=[16, 5, 11, 9]
)
data = Data([trace0, trace1])
py.plot(data, filename = 'basic-line2')
Out[4]:
In [5]:
import plotly.plotly as py
from plotly.graph_objs import *
trace0 = Scatter(
x=[1, 2, 3, 4],
y=[10, 15, 13, 17]
)
trace1 = Scatter(
x=[1, 2, 3, 4],
y=[16, 5, 11, 9]
)
data = Data([trace0, trace1])
py.iplot(data, filename = 'basic-line')
Out[5]:
In [5]:
import plotly
from plotly.graph_objs import Scatter, Layout
plotly.offline.plot({
"data": [Scatter(x=[1, 2, 3, 4], y=[4, 3, 2, 1])],
"layout": Layout(title="hello world")
})
Out[5]:
In [3]:
import plotly
from plotly.graph_objs import Scatter, Layout
# init code
plotly.offline.init_notebook_mode(connected=True)
plotly.offline.iplot({
"data": [Scatter(x=[1, 2, 3, 4], y=[4, 3, 2, 1])],
"layout": Layout(title="hello world")
})
Minimal HTML and no JS. Pure Python based dashboards. More info here: https://plot.ly/dash/