I am creating a plotly view in which I use an updatemenu to allow the user to switch between different images. The structure of each image is the same, see the example below:
At the top of the figure I want to present a table (with dynamic row length) and below it a figure. Right now I am trying to use the yellow βVoxβ symbol. However, this figure is presented on an axes system because in my make_subplots call I need to define a spec and have set this to scatter. My question is how I can create subplots within an updatemenu structure with 2 rows and 1 column where the first row is a table and the second row is a static image.
This is what I currently have (I have replaced some variables to make the code work):
fig = make_subplots(rows=2, cols=1,
vertical_spacing=0.03,
specs=[[{"type": "table"}],
[{"type": "scatter"}]]
)
buttons = []
user_groups = [1, 2]
for ix_group, group in enumerate(user_groups):
visible_list = [False] * len(user_groups)
table_content = [[1], [1], [1], [1], [1], [1]]
fig.add_trace(
go.Table(
header=dict(
values=["Niveau<br>[m NAP]","Rc;d;net<br>[kN]", "Rc;cal;gem<br>[kN]",
"Rc;cal;min<br>[kN]", "VAR<br>[%]", "Maatgevende ΞΎ"],
font_size=14,
align="left"
),
cells=dict(
values=table_content,
align="left")
),
row=1, col=1
)
# Add image
fig.add_layout_image(
dict(
source="https://raw.githubusercontent.com/cldougl/plot_images/add_r_img/vox.png",
xref="paper", yref="paper",
x=0, y=1.05,
sizex=0.2, sizey=0.2,
xanchor="right", yanchor="bottom"
),
row=2, col=1
)
visible_list[ix_group] = True
button = dict(
label='temp_label',
method='update',
args=[{'visible': visible_list},
{'title': 'test_title'}]
)
buttons.append(button)
fig.update_layout(
updatemenus=[
dict(
buttons=buttons,
pad={"r": 10, "t": 8},
showactive=True,
x=0.08,
xanchor="left",
y=1.05,
yanchor="middle"
)
],
annotations=[dict(text="Groep:", showarrow=False,
x=0, y=1.05, xanchor='left', yanchor='middle', xref='paper', yref='paper')]
)