Hi guys. I want to show two charts, linked by their x-axis:
- Top chart, with one trace
- Bottom chart with two traces, each with its own y-axis
I can do it in the online creator, however Iβm unable to do it from the Python API.
Am I missing a keyword?
# Imports
import numpy as np
from plotly.tools import make_subplots
import plotly.plotly as py
import plotly.graph_objs as go
# Traces
# top Trace
t = go.Scatter(
x = x_range,
y = x_range**2,
yaxis = 'y1',
name = 'T')
# bottom left-axis trace
bl = go.Scatter(
x = x_range,
y = x_range**0.5,
yaxis = 'y2',
name = "BL")
# bottom right-axis trace
br = go.Scatter(
x = x_range,
y = np.log(x_range+1),
yaxis = 'y3',
name = "BR")
# Create Fig with subplots
fig = make_subplots(rows=2, cols=1, specs=[[{}], [{}]],
shared_xaxes=True, shared_yaxes=False,
vertical_spacing=0.01)
fig.append_trace(t, 1, 1)
fig.append_trace(bl, 2, 1)
fig.append_trace(br, 2, 1)
# Layout
fig['layout']['yaxis1'].update(title='Top')
fig['layout']['yaxis2'].update(title='Bottom-left')
fig['layout']['yaxis3'].update(title='Bottom-right', side='right', overlaying='y2')
# Plot
py.iplot(fig)
Iβve added the y3
value to the y-axis
attribute of the bottom right trace,
Still the result is not satisfactory as the y-3 axis (bottom right) does not command the βbrβ trace. See result here: https://plot.ly/~patricio.panichelli.hw/56/t-bl-br/
What am I missing? Is there anything Iβm doing wrong?
Any help will be very much appreciated! Thanks!