I am trying to display the table behind a scatter plot using dropdown menus. The problem I am facing is the display of the Table when clicking on Table option, and back to scatter. Both Charts are displayed on top of each other when clicking on Table. Only the first render is done correctly displaying the scatter plot.
import plotly.graph_objects as go
values = ['A Scores', 'B Scores']
x = [100, 90, 80, 90]
y = [95, 85, 75, 95]
fig = go.Figure()
fig.add_trace(go.Scatter(x=x,
y=y,
mode='markers',
))
fig.add_trace(go.Table(
header=dict(values=values),
cells=dict(values=[x,y]),
visible= False,
))
# Add dropdown
fig.update_layout(
updatemenus=[
dict(
active=0,
buttons=list([
dict(label="Scatter",
method="update",
args=[{"visible": [True, False]},
{"title": "Scatter"}]),
dict(label="Table",
method="update",
args=[{"visible": [False, True]},
{"title": "Table"}]),
]),
)
])
fig.show()