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!
In [1]:
import plotly
plotly.__version__
Out[1]:
In [5]:
import plotly.plotly as py
import plotly.graph_objs as go
import numpy as np
x = np.random.randn(500)
data = [
go.Histogram(
x=x
)
]
py.iplot(data)
Out[5]:
In [6]:
import plotly.plotly as py
import plotly.graph_objs as go
import numpy as np
x = np.random.randn(500)
data = [
go.Histogram(
x=x,
histnorm='probability'
)
]
py.iplot(data)
Out[6]:
In [7]:
import plotly.plotly as py
import plotly.graph_objs as go
import numpy as np
y = np.random.randn(500)
data = [
go.Histogram(
y=y
)
]
py.iplot(data)
Out[7]:
In [8]:
import plotly.plotly as py
import plotly.graph_objs as go
import numpy as np
x0 = np.random.randn(500)
x1 = np.random.randn(500)+1
trace1 = go.Histogram(
x=x0,
opacity=0.75
)
trace2 = go.Histogram(
x=x1,
opacity=0.75
)
data = [trace1, trace2]
layout = go.Layout(
barmode='overlay'
)
fig = go.Figure(data=data, layout=layout)
py.iplot(fig)
Out[8]:
In [9]:
import plotly.plotly as py
import plotly.graph_objs as go
import numpy as np
x0 = np.random.randn(500)
x1 = np.random.randn(500)+1
trace1 = go.Histogram(
x=x0
)
trace2 = go.Histogram(
x=x1
)
data = [trace1, trace2]
layout = go.Layout(
barmode='stack'
)
fig = go.Figure(data=data, layout=layout)
py.iplot(fig)
Out[9]:
In [10]:
import plotly.plotly as py
import plotly.graph_objs as go
import numpy as np
x0 = np.random.randn(500)
x1 = np.random.randn(500)+1
trace1 = go.Histogram(
x=x0,
histnorm='count',
name='control',
autobinx=False,
xbins=dict(
start=-3.2,
end=2.8,
size=0.2
),
marker=dict(
color='fuchsia',
line=dict(
color='grey',
width=0
)
),
opacity=0.75
)
trace2 = go.Histogram(
x=x1,
name='experimental',
autobinx=False,
xbins=dict(
start=-1.8,
end=4.2,
size=0.2
),
marker=dict(
color='rgb(255, 217, 102)'
),
opacity=0.75
)
data = [trace1, trace2]
layout = go.Layout(
title='Sampled Results',
xaxis=dict(
title='Value'
),
yaxis=dict(
title='Count'
),
barmode='overlay',
bargap=0.25,
bargroupgap=0.3
)
fig = go.Figure(data=data, layout=layout)
py.iplot(fig)
Out[10]:
See https://plot.ly/python/reference/#histogram for more information and chart attribute options!
In [ ]: