I have Python Dash App which displays a Plotly graph_object.scatter plot with multiple traces that I can switch between using a layout.updatemenus[] dropdown menu.
The problem that I'm facing is that depending on which dropdown menu option is selected, the x-axis and y-axis should have different titles.
As of now, neither axis has any title, but I can add a permanent title (that is, one that does not change dynamically based on which trace is showing) by using the xaxis_title and yaxis_title attributes of the figure.update_layout method. I cannot, however, pass a list or a dictionary for xaxis_title or yaxis_title (it only accepts a string or an int).
I'm currently envisioning a series of if/else statements that finds which dropdown menu option currently has 'ShowActive' set to True and changes the xaxis_title and yaxis_title attributes based on that. But I don't know how to write it so that this axis-title-changing function will run whenever a new menu option is selected.
I can update this question with code samples if necessary.