Plotly's Python library is free and open source! Get started by downloading the client and reading the primer.
You can set up Plotly to work in online or offline mode, or in jupyter notebooks.
We also have a quick-reference cheatsheet (new!) to help you get started!
import plotly.plotly as py
import plotly.graph_objs as go
import numpy as np
trace1 = go.Scatter(
x=np.random.randn(75),
mode='markers',
name="Plot1",
marker=dict(
size=16,
color='rgba(152, 0, 0, .8)'
))
trace2 = go.Scatter(
x=np.random.randn(75),
mode='markers',
name="Plot2",
marker=dict(
size=16,
color='rgba(0, 152, 0, .8)'
))
trace3 = go.Scatter(
x=np.random.randn(75),
mode='markers',
name="Plot3",
marker=dict(
size=16,
color='rgba(0, 0, 152, .8)'
))
data = [trace1, trace2, trace3]
layout = go.Layout(
legend=dict(
orientation="h")
)
figure=go.Figure(data=data, layout=layout)
py.iplot(figure)
See https://plotly.com/python/reference/#layout-legend-orientation for more information and chart attribute options!
from IPython.display import display, HTML
display(HTML('<link href="//fonts.googleapis.com/css?family=Open+Sans:600,400,300,200|Inconsolata|Ubuntu+Mono:400,700rel="stylesheet" type="text/css" />'))
display(HTML('<link rel="stylesheet" type="text/csshref="http://help.plot.ly/documentation/all_static/css/ipython-notebook-custom.css">'))
! pip install git+https://github.com/plotly/publisher.git --upgrade
import publisher
publisher.publish(
'horizontal-legends.ipynb', 'python/horizontal-legend/', 'Horizontal legend | plotly',
'How to add images to charts as background images or logos.',
title = 'Horizontal legend | plotly',
name = 'Horizontal Legends',
has_thumbnail='false', thumbnail='thumbnail/your-tutorial-chart.jpg',
language='python', page_type='example_index',
display_as='style_opt', order=12,
ipynb= '~notebook_demo/94')
Collecting git+https://github.com/plotly/publisher.git Cloning https://github.com/plotly/publisher.git to /var/folders/ld/6cl3s_l50wd40tdjq2b03jxh0000gp/T/pip-7f1J4I-build Installing collected packages: publisher Found existing installation: publisher 0.10 Uninstalling publisher-0.10: Successfully uninstalled publisher-0.10 Running setup.py install for publisher ... - \ done Successfully installed publisher-0.10
/Users/brandendunbar/Desktop/test/venv/lib/python2.7/site-packages/IPython/nbconvert.py:13: ShimWarning: The `IPython.nbconvert` package has been deprecated. You should import from nbconvert instead. "You should import from nbconvert instead.", ShimWarning) /Users/brandendunbar/Desktop/test/venv/lib/python2.7/site-packages/publisher/publisher.py:53: UserWarning: Did you "Save" this notebook before running this command? Remember to save, always save. warnings.warn('Did you "Save" this notebook before running this command? '