How to have multiple x-axis for plotly express?


I have the code below, and I want to add various parameters to one chart using the dropdown menu.
However, the ranges of parameters are quite different and when they are plotted, they look like a straight line. I want to be able to add multiple X-axis.

I searched it on the web, and plotly documents. here is a way to add a secondary Y-axis adding secondary y-axis

There are only a few posts available for adding x-axis but they are also implementing plotly.graph_objects and not the

from dash.exceptions import PreventUpdate
import as px
import pandas as pd
import numpy as np
import dash_bootstrap_components as dbc


app = Dash(__name__, external_stylesheets=[dbc.themes.SUPERHERO])

app.layout = html.Div([
        html.Button('Add Chart', id='add-chart', n_clicks=0),
    html.Div(id='container', children=[])

    Output('container', 'children'),
    [Input('add-chart', 'n_clicks')],
    [State('container', 'children')]
def display_graphs(n_clicks, div_children):
    new_child = html.Div(
        style={'width': '25%',
               'display': 'inline-block',
               'outline': 'thin lightgrey solid',
               'padding': 10},

            dcc.Dropdown(id={'type': 'feature-choice',
                             'index': n_clicks},
            dcc.Graph(id={'type': 'dynamic-graph',
                          'index': n_clicks},
    return div_children

    Output({'type': 'dynamic-graph', 'index': MATCH}, 'figure'),
    [Input({'type': 'feature-choice', 'index': MATCH}, 'value')]
def update_graph(X):
    if X is None:
        raise PreventUpdate
    fig1 = px.line(df, x=X, y='col3')
        {'height': 600,
         'legend': {'title': '', 'x': 0, 'y': 1.06, 'orientation': 'h'},
         'margin': {'l': 0, 'r': 20, 't': 50, 'b': 0}
    return fig1

if __name__ == '__main__':

Hi @Peyman ,

in the link you postetd it is stated, that does not support dual axis, yet you are searching for a solution in

Did you see this post?

1 Like

Thanks for the reply. Can I simply replace the GO plots with plotly express? and if I have more than 2 x-axis, then is there a way?

As I understand, does NOT support dual axes. You would have to use plotly.graph_objects as in the example from the link.