# Setup Dropdown with two subplot figure

**URL:** https://community.plotly.com/t/setup-dropdown-with-two-subplot-figure/82469
**Category:** 📊 Plotly Python
**Created:** [February 20, 2024, 8:12am UTC](https://community.plotly.com/t/setup-dropdown-with-two-subplot-figure/82469 "2024-02-20T08:12:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Eng-DATA\_FR](https://avatars.discourse-cdn.com/v4/letter/e/3d9bf3/32.png) [@Eng-DATA\_FR](https://community.plotly.com/u/Eng-DATA_FR)
#### Post date: [February 20, 2024, 8:12am UTC](https://community.plotly.com/t/setup-dropdown-with-two-subplot-figure/82469/1 "2024-02-20T08:12:41Z")

</div>

I’m trying to concatenate two figure subplots in Plotly, but I’m encountering issues because the datasets used in the two subplots don’t have the same datetime in the x-axis and layout. Additionally, I’m using widgets to switch between the data subplots.

My ultimate goal is to switch from a dataset to an other thanks to widget label, please find the code here :

```auto
fig1 = make_subplots(rows=1, cols=3)
fig1 = tracer_courbes(fig1, 1, DATA_PREVIOUS_A, DATA_PREVIOUS_A_02, DATA_CURRENT_A)

fig2 = make_subplots(rows=1, cols=3)
fig2 = tracer_courbes(fig2, 1, _DATA_PREVIOUS_A, _DATA_PREVIOUS_A_02, _DATA_CURRENT_A)

# Update layout for figure 1
fig1.update_layout(title_text="Subplot 1",
                    showlegend=False)

# Update layout for figure 2
fig2.update_layout(title_text="Subplot 2",
                    showlegend=False)

# Adjust x-axis and y-axis ranges to match each other
fig1.layout.xaxis.update(range=fig2.layout.xaxis.range)
fig1.layout.yaxis.update(range=fig2.layout.yaxis.range)

# Create a dropdown menu to select between figures
dropdown = [
    {'label': 'Subplot 1', 'method': 'update', 'args': [{'visible': [True, True, True]}, {'title': 'Subplot 1'}]},
    {'label': 'Subplot 2', 'method': 'update', 'args': [{'visible': [True, True, True]}, {'title': 'Subplot 2'}]}
]

# Combine the two figures into one
fig = go.Figure(data=fig1.data + fig2.data, layout=fig1.layout)

# Add dropdown menu to switch between figures
fig.update_layout(updatemenus=[{'buttons': dropdown,
                                'direction': 'down',
                                'showactive': True,
                                'x': 0.1,
                                'xanchor': 'left',
                                'y': 1.1,
                                'yanchor': 'top'}])

```

---

<div class="post-metadata">

### Author: ![Eng-DATA\_FR](https://avatars.discourse-cdn.com/v4/letter/e/3d9bf3/32.png) [@Eng-DATA\_FR](https://community.plotly.com/u/Eng-DATA_FR)
#### Post date: [February 22, 2024, 1:34pm UTC](https://community.plotly.com/t/setup-dropdown-with-two-subplot-figure/82469/2 "2024-02-22T13:34:06Z")

</div>

**someone** has the right way to do it without dash please ?

---

<div class="post-metadata">

### Author: ![farispriadi](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/farispriadi/32/26759_2.png) [@farispriadi](https://community.plotly.com/u/farispriadi)
#### Post date: [February 23, 2024, 11:10pm UTC](https://community.plotly.com/t/setup-dropdown-with-two-subplot-figure/82469/3 "2024-02-23T23:10:14Z")

</div>

Hi @Eng-DATA_FR ,

Can you provide us data samples, which will help us a lot to reproduce your issues.  
Thanks.
