Changing the xy-Axis Titles with Dropdown Menu


Is it possible to change the titles of the x and y axis whenever we use the “update” method of the Dropdown menu (

Thank you

1 Like

@Fxs7576 you’ll need to add your axis titles to the button args.

Here’s an example of how the updatemenus list could be modified to produce different axis labels for each plot:

updatemenus = list([
            dict(label = 'High',
                 method = 'update',
                 args = [{'visible': [True, True, False, False]},
                         {'title': 'Yahoo High',
                          'xaxis': {'title': 'Date'},
                          'yaxis': {'title': 'High Price - Dollars'},
                          'annotations': high_annotations}]),
            dict(label = 'Low',
                 method = 'update',
                 args = [{'visible': [False, False, True, True]},
                         {'title': 'Yahoo Low',
                          'xaxis': {'title': 'Date'},
                          'yaxis': {'title': 'Low Price - Dollars'},
                          'annotations': low_annotations}]),
            dict(label = 'Both',
                 method = 'update',
                 args = [{'visible': [True, True, True, True]},
                         {'title': 'Yahoo',
                          'xaxis': {'title': 'Date'},
                          'yaxis': {'title': 'High & Low Price - Dollars'},
                          'annotations': high_annotations+low_annotations}]),
            dict(label = 'Reset',
                 method = 'update',
                 args = [{'visible': [True, False, True, False]},
                         {'title': 'Yahoo',
                          'xaxis': {'title': 'Date'},
                          'yaxis': {'title': 'Price - Dollars'},
                          'annotations': []}])
1 Like

Hey! Here’s code for used cases in a dynamic real time menus/ general menus.

L1=[X title1, X title2, X title3 … ,X titleN]
L2=[Y title1,…,Y titleN]

updatemenus = list([dict(active=Max, buttons=list([
dict(label = label[k],
method = ‘update’,
args = [{‘visible’:[True if k==j else False for j in range(N)]},
{‘title’: ‘Loan Satus Vs Feature’,
‘xaxis’: {‘title’: L1[k]},
‘yaxis’: {‘title’: L2[k]}}],

                 ) for k in range(N)]