Hello all.
Goal
Say I have a plot like this.
I would like to use the Plotly buttons to move a trace from the y1 axis to the y2 axis, like this.
I have already implemented similar functionality in Dash, but I would like this to use Plotly buttons so that I can save the plots as .html and not have a Python kernel supporting the application.
Question to Achieve that Goal
I have scoured the documentation but I can’t quite understand how the updatemenus work.
For instance, in the custom buttons example, how do you know what args you can specify within the updatemenu button.
# Add dropdown
fig.update_layout(
updatemenus=[
dict(
type = "buttons",
direction = "left",
buttons=list([
dict(
args=["type", "surface"],
label="3D Surface",
method="restyle"
),
dict(
args=["type", "heatmap"],
label="Heatmap",
method="restyle"
)
]),
pad={"r": 10, "t": 10},
showactive=True,
x=0.11,
xanchor="left",
y=1.1,
yanchor="top"
),
]
)
In this example they ues “type” and “surface”, but where specifically do those args go to? What other args could I specify? If someone could point me in the direction of additional documentation so that I could truly understand and then solve the problem myself, that would be great.
Ideas for Solution
One way to do this would be to create a button for each trace on the plot and when pressed that button goes into the properties for that traces and sets the ‘yaxis’ property to ‘y2’. Similar to what this line of code does.
fig.update_traces(yaxis='y2', selector=dict(name='Trace 2'))
Another idea for this is to just create two traces for all the columns of data, one on each y-axis, and only show the trace that is on the desired y-axis.
Thank you