Toggle between 2 xaxis values

I want to know if it’s possible to create button that toggle showed values of xaxis?
My first aproach was to create 2 buttons and change ‘x’ values on it ‘arg’.

  • It work if I have only 1 line plot. With multiple line plot doesn’t work.
    2nd aproach is to define 2 different ‘xaxis’ and alternate between both in button ‘arg’
  • Only change xaxis title don’t change values

Example code:

def add_toggle_xaxis(plot, values1, values2):
    my_buttons = [{'label': 'Values1', 'method': 'update', 'args':[{'xaxis':'x2'}], 'args2':[{'xaxis':'x3'}]}]
    toggle_button = dict(type='buttons', buttons=my_buttons, direction='down', active=1, x=0, xanchor='left', y=0, yanchor='top')
    plot.update_layout(xaxis2=dict(title='Title Values 1', tickvals=values1))
    plot.update_layout(xaxis3=dict(title='Title Values 2', tickvals=values2))
    plot.update_layout(updatemenus=[toggle_button])
    return plot

@nicolaskruchten you know solution for that?