python==3.8 plotly==4.10.0
With plotly settings I'm going to add something I use often
from plotly.subplots import make_subplots
import plotly.graph_objects as go
fig = make_subplots(rows=1, cols=2)
fig.add_trace(go.Scatter(y=[4, 2, 1], mode="lines"), row=1, col=1)
fig.add_trace(go.Bar(y=[2, 1, 3]), row=1, col=2)
fig.show()
from plotly.subplots import make_subplots
import plotly.graph_objects as go
fig = make_subplots(rows=1, cols=2)
fig.add_trace(go.Scatter(y=[4, 2, 1], mode="lines"), row=1, col=1)
fig.add_trace(go.Bar(y=[2, 1, 3]), row=1, col=2)
fig.update_layout(
margin=dict(l=20, r=20, t=20, b=20),
paper_bgcolor="LightSteelBlue",
)
fig.show()
from plotly.subplots import make_subplots
import plotly.graph_objects as go
fig = make_subplots(rows=1, cols=2)
fig.add_trace(go.Scatter(y=[4, 2, 1], mode="lines"), row=1, col=1)
fig.add_trace(go.Bar(y=[2, 1, 3]), row=1, col=2)
fig.update_layout(
margin=dict(l=20, r=20, t=20, b=20),
paper_bgcolor="LightSteelBlue",
)
fig.update_xaxes(title_text="xlabel")
fig.update_yaxes(title_text="ylabel", hoverformat=".3f")
fig.show()
bar and scattor can be specified as make_subplots, pie and scatter3D cannot be specified as they are Tell make_subplots what you want to specify
from plotly.subplots import make_subplots
import plotly.graph_objects as go
fig = make_subplots(
rows=2, cols=2,
specs=[[{"type": "bar"}, {"type": "barpolar"}],
[{"type": "pie"}, {"type": "scatter3d"}]],
)
fig.add_trace(go.Bar(y=[2, 3, 1]),row=1, col=1)
fig.add_trace(go.Barpolar(theta=[0, 45, 90], r=[2, 3, 1]),row=1, col=2)
fig.add_trace(go.Pie(values=[2, 3, 1]),row=2, col=1)
fig.add_trace(go.Scatter3d(x=[2, 3, 1], y=[0, 0, 0], z=[0.5, 1, 2], mode="lines"),row=2, col=2)
fig.update_layout(height=700, showlegend=False)
fig.show()
Postscript record
2020-09-27 Created
Recommended Posts