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
data = [
go.Scatter(
x=[0, 1, 2],
y=[6, 10, 2],
error_y=dict(
type='data',
array=[1, 2, 3],
visible=True
)
)
]
py.iplot(data, filename='basic-error-bar')
import plotly.plotly as py
import plotly.graph_objs as go
data = [
go.Scatter(
x=[1, 2, 3, 4],
y=[2, 1, 3, 4],
error_y=dict(
type='data',
symmetric=False,
array=[0.1, 0.2, 0.1, 0.1],
arrayminus=[0.2, 0.4, 1, 0.2]
)
)
]
py.iplot(data, filename='error-bar-asymmetric-array')
import plotly.plotly as py
import plotly.graph_objs as go
data = [
go.Scatter(
x=[0, 1, 2],
y=[6, 10, 2],
error_y=dict(
type='percent',
value=50,
visible=True
)
)
]
py.iplot(data, filename='percent-error-bar')
import plotly.plotly as py
import plotly.graph_objs as go
data = [
go.Scatter(
x=[1, 2, 3, 4],
y=[2, 1, 3, 4],
error_y=dict(
type='percent',
symmetric=False,
value=15,
valueminus=25
)
)
]
py.iplot(data, filename='error-bar-asymmetric-constant')
import plotly.plotly as py
import plotly.graph_objs as go
data = [
go.Scatter(
x=[1, 2, 3, 4],
y=[2, 1, 3, 4],
error_x=dict(
type='percent',
value=10
)
)
]
py.iplot(data, filename='error-bar-horizontal')
import plotly.plotly as py
import plotly.graph_objs as go
trace1 = go.Bar(
x=['Trial 1', 'Trial 2', 'Trial 3'],
y=[3, 6, 4],
name='Control',
error_y=dict(
type='data',
array=[1, 0.5, 1.5],
visible=True
)
)
trace2 = go.Bar(
x=['Trial 1', 'Trial 2', 'Trial 3'],
y=[4, 7, 3],
name='Experimental',
error_y=dict(
type='data',
array=[0.5, 1, 2],
visible=True
)
)
data = [trace1, trace2]
layout = go.Layout(
barmode='group'
)
fig = go.Figure(data=data, layout=layout)
py.iplot(fig, filename='error-bar-bar')
import plotly.plotly as py
import plotly.graph_objs as go
import numpy as np
x_theo = np.linspace(-4, 4, 100)
sincx = np.sinc(x_theo)
x = [-3.8, -3.03, -1.91, -1.46, -0.89, -0.24, -0.0, 0.41, 0.89, 1.01, 1.91, 2.28, 2.79, 3.56]
y = [-0.02, 0.04, -0.01, -0.27, 0.36, 0.75, 1.03, 0.65, 0.28, 0.02, -0.11, 0.16, 0.04, -0.15]
trace1 = go.Scatter(
x=x_theo,
y=sincx,
name='sinc(x)'
)
trace2 = go.Scatter(
x=x,
y=y,
mode='markers',
name='measured',
error_y=dict(
type='constant',
value=0.1,
color='#85144B',
thickness=1.5,
width=3,
),
error_x=dict(
type='constant',
value=0.2,
color='#85144B',
thickness=1.5,
width=3,
),
marker=dict(
color='#85144B',
size=8
)
)
data = [trace1, trace2]
py.iplot(data, filename='error-bar-style')
See https://plotly.com/python/reference/#scatter 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,700" rel="stylesheet" type="text/css" />'))
display(HTML('<link rel="stylesheet" type="text/css" href="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(
'error-bars.ipynb', 'python/error-bars/', 'Error Bars | plotly',
'How to add error-bars to charts in Python with Plotly.',
title = 'Error Bars | plotly',
name = 'Error Bars',
thumbnail='thumbnail/error-bar.jpg', language='python',
page_type='example_index', has_thumbnail='true', display_as='statistical', order=1,
ipynb='~notebook_demo/18')
Collecting git+https://github.com/plotly/publisher.git Cloning https://github.com/plotly/publisher.git to /private/var/folders/tc/bs9g6vrd36q74m5t8h9cgphh0000gn/T/pip-req-build-FHZDff Building wheels for collected packages: publisher Running setup.py bdist_wheel for publisher ... done Stored in directory: /private/var/folders/tc/bs9g6vrd36q74m5t8h9cgphh0000gn/T/pip-ephem-wheel-cache-gwfx1n/wheels/99/3e/a0/fbd22ba24cca72bdbaba53dbc23c1768755fb17b3af0f33966 Successfully built publisher Installing collected packages: publisher Found existing installation: publisher 0.11 Uninstalling publisher-0.11: Successfully uninstalled publisher-0.11 Successfully installed publisher-0.11
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/nbconvert.py:13: ShimWarning: The `IPython.nbconvert` package has been deprecated since IPython 4.0. You should import from nbconvert instead. /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/publisher/publisher.py:53: UserWarning: Did you "Save" this notebook before running this command? Remember to save, always save.