I have a dataframe of multiple columns, each containing a time series. I want to compare two time series plots at a time, for which I am plotting them overlayed with two y-axes as given in the example here: https://plot.ly/python/multiple-axes/#two-y-axes
My problems are:
I want plotly to let the user select only two traces at a time,
dynamically change and adjust the y-axis based on which trace is selected/un-selected
Building on the example given in the link above:
import plotly
import plotly.plotly as py
import plotly.graph_objs as go
trace1 = go.Scatter(x=[1, 2, 3],y=[40, 50, 60],name='yaxis data')
trace2 = go.Scatter(x=[2, 3, 4],y=[4, 5, 6],name='yaxis2 data',yaxis='y2')
trace3 = go.Scatter( x=[3, 4, 5],y=[400, 500, 600],name='yaxis3 data', yaxis='y2', visible = 'legendonly')
data = [trace1, trace2, trace3]
layout = go.Layout(
title='Double Y Axis Example',
yaxis=dict(
title='yaxis title'
),
yaxis2=dict(
title='yaxis2 title',
titlefont=dict(
color='rgb(148, 103, 189)'
),
tickfont=dict(
color='rgb(148, 103, 189)'
),
overlaying='y',
side='right'
)
)
fig = go.Figure(data=data, layout=layout)
plotly.offline.plot(fig)
So plotly should let the user choose only two traces at a time to be visible on the plot, and dynamically put the next selected trace on the available y-axis side.
For example if 'yaxis data' and 'yaxis2 data' are visible, the user has to unselect either of those before selecting 'yaxis3 data' from the legends. So if the user unselects 'yaxis data' which is on the left hand side of the plot, 'yaxis3 data's y-axis labels should go on the left hand side. IF the user had unselected 'yaxis2 data', the new data would go on the right hand side.
I want the yaxis= 'y' or 'y2'
to be assigned through the interactive session. I dont know how to achieve that.