Plotly (https://plot.ly) is a collaborative data analysis and graphing platform. Plotly's IPython Graphing Library (https://plot.ly/python) interfaces Plotly's online graphing tools with your IPython notebook environment. Send data to your Plotly account, embed the graphs in your IPython notebook, and share them in your web browser. Style with code or with our online interface; share your work publicly with a url or privately among other Plotly members; access your graphs from anywhere. Learn More
p = plotly.plotly('IPython.Demo', '1fw3zw2o13')
p.verbose=False
import numpy as np
x0 = np.concatenate([np.random.randn(100), np.random.randn(100)+6])
y0 = np.random.rayleigh(size=200)
data = [
{
"x": x0,
"y": y0,
"type": "histogram2d"
},
{
"y": y0,
"type": "histogramy",
"xaxis": "x2",
"yaxis": "y",
"bardir": "h",
"marker":{"color":"rgb(31, 119, 180)"}
},
{
"x":x0,
"type": "histogramx",
"xaxis": "x",
"yaxis": "y3",
"marker":{"color":"rgb(31, 119, 180)"}
}
]
layout = {
"showlegend":False,
"width":900,
"height": 700,
"xaxis":{
"domain":[0,0.8],
"showgrid":False,
"showline":False,
"zeroline":False
},
"yaxis":{
"domain":[0,0.8],
"showgrid":False,
"showline":False,
"zeroline":False
},
"xaxis2":{
"domain":[0.82,1.0],
"showgrid":False,
"showline":False,
"zeroline":False
},
"yaxis3":{
"domain":[0.82,1.0],
"showgrid":False,
"showline":False,
"zeroline":False
}
}
p.iplot(data,layout=layout,width=950,height=750)
data = [
{
"x":[2,3,4],
"y":[4,5,6],
"yaxis":"y2", # this will reference the yaxis2 object in the layout object
"name": "yaxis2 data"
},
{
"x":[1,2,3],
"y":[40,50,60],
"name":"yaxis data"
}
];
layout = {
"yaxis":{
"title": "yaxis title", # optional
},
"yaxis2":{
"title": "yaxis2 title", # optional
"titlefont":{
"color":"rgb(148, 103, 189)"
},
"tickfont":{
"color":"rgb(148, 103, 189)"
},
"overlaying":"y",
"side":"right",
},
"title": "Double Y Axis Example",
"annotations": [{"text":"This plot is interactive!<br>Try panning one of the axes<br>(click-and-drag on the axes-borders)<br>or zooming (click-and-drag) in the plot",
"align":"left",
"showarrow":False,
"x":0.05, "y":0.93, "xref": "page", "yref": "page"}]
}
p.iplot(data, layout=layout)
c = ['#1f77b4', # muted blue
'#ff7f0e', # safety orange
'#2ca02c', # cooked asparagus green
'#d62728', # brick red
'#9467bd', # muted purple
'#8c564b', # chestnut brown
'#e377c2', # raspberry yogurt pink
'#7f7f7f', # middle gray
'#bcbd22', # curry yellow-green
'#17becf']; #blue-teal
data = [
{
"x":[1,2,3],
"y":[4,5,6],
"name":"yaxis1 data"
},
{
"x":[2,3,4],
"y":[40,50,60],
"name":"yaxis2 data",
"yaxis":"y2"
},
{
"x":[3,4,5],
"y":[400,500,600],
"name":"yaxis3 data",
"yaxis":"y3"
},
{
"x":[4,5,6],
"y":[40000,50000,60000],
"name":"yaxis4 data",
"yaxis":"y4"
},
{
"x":[5,6,7],
"y":[400000,500000,600000],
"name":"yaxis5 data",
"yaxis":"y5"
},
{
"x":[6,7,8],
"y":[4000000,5000000,6000000],
"name":"yaxis6 data",
"yaxis":"y6"
},
]
layout = {
"width":800,
"xaxis":{
"domain":[0.3,0.7]
},
"yaxis":{
"title": "yaxis title",
"titlefont":{
"color":c[0]
},
"tickfont":{
"color":c[0]
},
},
"yaxis2":{
"overlaying":"y",
"side":"left",
"anchor":"free",
"position":0.15,
"title": "yaxis2 title",
"titlefont":{
"color":c[1]
},
"tickfont":{
"color":c[1]
},
},
"yaxis3":{
"overlaying":"y",
"side":"left",
"anchor":"free",
"position":0,
"title": "yaxis3 title",
"titlefont":{
"color":c[2]
},
"tickfont":{
"color":c[2]
},
},
"yaxis4":{
"overlaying":"y",
"side":"right",
"anchor":"x",
"title": "yaxis4 title",
"titlefont":{
"color":c[3]
},
"tickfont":{
"color":c[3]
},
},
"yaxis5":{
"overlaying":"y",
"side":"right",
"anchor":"free",
"position":0.85,
"title": "yaxis5 title",
"titlefont":{
"color":c[4]
},
"tickfont":{
"color":c[4]
},
},
"yaxis6":{
"overlaying":"y",
"side":"right",
"anchor":"free",
"position":1.0,
"title": "yaxis6 title",
"titlefont":{
"color":c[5]
},
"tickfont":{
"color":c[5]
},
}
}
p.iplot(data, layout=layout)
data = [
{
"x":[1,2,3],
"y":[4,5,6],
},
{
"x":[20,30,40],
"y":[50,60,70],
"xaxis":"x2",
"yaxis":"y2"
}
]
layout = {
"xaxis":{
"domain":[0,0.45] # i.e. let the first x-axis span the first 45% of the plot width
},
"xaxis2":{
"domain":[0.55,1] # i.e. let the second x-axis span the latter 45% of the plot width
},
"yaxis2":{
"anchor":"x2" # i.e. bind the second y-axis to the start of the second x-axis
}
}
p.iplot(data, layout=layout)
data = [
{
"x":[1,2,3],
"y":[4,5,6],
},
{
"x":[20,30,40],
"y":[50,60,70],
"xaxis":"x2",
"yaxis":"y2"
}
]
layout = {
"xaxis":{
"domain":[0,0.7] # i.e. let the first x-axis span the first 70% of the plot width
},
"xaxis2":{
"domain":[0.8,1] # i.e. let the second x-axis span the latter 20% of the plot width
},
"yaxis2":{
"anchor":"x2" # i.e. bind the second y-axis to the start of the second x-axis
}
}
p.iplot(data, layout=layout)
data = [
{
"x":[1,2,3],
"y":[4,5,6],
},
{
"x":[20,30,40],
"y":[50,60,70],
"xaxis":"x2",
"yaxis":"y2"
},
{
"x":[300,400,500],
"y":[600,700,800],
"xaxis":"x3",
"yaxis":"y3"
},
{
"x":[4000,5000,6000],
"y":[7000,8000,9000],
"xaxis":"x4",
"yaxis":"y4"
}
]
layout = {
"xaxis":{
"domain":[0,0.45] # let the first x-axis span the first 45% of the plot width
},
"yaxis":{
"domain":[0,0.45] # # and let the first y-axis span the first 45% of the plot height
},
"xaxis2":{
"domain":[0.55,1] # and let the second x-axis span the latter 45% of the plot width
},
"yaxis2":{
"domain":[0,0.45], # and let the second y-axis span the first 45% of the plot height
"anchor":"x2" # bind the horizontal position of the second y-axis to the start of the second x-axis
},
"xaxis3":{
"domain":[0,0.45],
"anchor":"y3" # bind the vertical position of this axis to the start of yaxis3
},
"yaxis3":{
"domain":[0.55,1],
},
"xaxis4":{
"domain":[0.55,1],
"anchor":"y4", # bind the vertical position of this axis to the start of yaxis4
},
"yaxis4":{
"domain":[0.55,1],
"anchor":"x4" # bind the horizontal position of this axis to the start of xaxis4
}
}
p.iplot(data, layout=layout)
data = [
{
"x":[1,2,3],
"y":[2,3,4],
},
{
"x":[20,30,40],
"y":[5,5,5],
"xaxis":"x2",
"yaxis":"y"
},
{
"x":[2,3,4],
"y":[600,700,800],
"xaxis":"x",
"yaxis":"y3"
},
{
"x":[4000,5000,6000],
"y":[7000,8000,9000],
"xaxis":"x4",
"yaxis":"y4"
}
]
layout = {
"xaxis":{
"domain":[0,0.45] # let the first x-axis span the first 45% of the plot width
},
"yaxis":{
"domain":[0,0.45] # # and let the first y-axis span the first 45% of the plot height
},
"xaxis2":{
"domain":[0.55,1] # and let the second x-axis span the latter 45% of the plot width
},
"yaxis3":{
"domain":[0.55,1],
},
"xaxis4":{
"domain":[0.55,1],
"anchor":"y4", # bind the vertical position of this axis to the start of yaxis4
},
"yaxis4":{
"domain":[0.55,1],
"anchor":"x4" # bind the horizontal position of this axis to the start of xaxis4
}
}
p.iplot(data, layout=layout)
data = [
{
"x":[1,2,3],
"y":[4,3,2],
},
{
"x":[20,30,40],
"y":[30,40,50],
"xaxis":"x2",
"yaxis":"y2"
}
]
layout = {
"xaxis2": {
"domain": [0.6, 0.95],
"anchor": "y2"
},
"yaxis2":{
"domain": [0.6, 0.95],
"anchor": "x2"
}
}
p.iplot(data, layout=layout)