Black Lives Matter. Please consider donating to Black Girls Code today.

Multiple Yaxis issue - previous traces disappears

I’m trying to add two traces with their own Y-Axis but as soon as I add 2nd trace, the 1st one disappears! Here’s very easy repro of this issue:

In Jupyter Notebook:

import plotly
import plotly.graph_objs as go
t1=go.Scatter(x=[0, 1, 2], y=[0, 1, 8], mode='lines')
f2=go.FigureWidget([t1])
f2

First trace is drawn correctly. Now add 2nd trace with different Y-Axis:

t2=go.Scatter(x=[4, 5, 6], y=[0, 1, 2], mode='lines', yaxis='y2')
f2.add_trace(t2)
yaxis2 = {'title':'Y2', 'side':'right'}
f2.layout['yaxis2']=yaxis2

Notice the first trace goes away! If you didn’t set separate yaxis on 2nd trace then it works fine.

Possibly related issue.

Hi @sytelus,

You’ll need to add the overlaying property to the second yaxis.

import plotly
import plotly.graph_objs as go
t1=go.Scatter(x=[0, 1, 2], y=[0, 1, 8], mode='lines')
f2=go.FigureWidget([t1])
t2=go.Scatter(x=[4, 5, 6], y=[0, 1, 2], mode='lines', yaxis='y2')
f2.add_trace(t2)
yaxis2 = {'title':'Y2', 'side':'right', 'overlaying': 'y'}
f2.layout['yaxis2']=yaxis2
f2

newplot(2)

Hope that helps!
-Jon