Iām beginner on Python plotpy, want to integrate multiple data on dropdown menu:
code:
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
#load csv file
df = pd.read_csv('output_file.csv')
df_visayas = pd.read_csv('davao.csv')
#labels
fig = px.scatter(df, x = 'datetime',
y = ['observed_tide', 'estimated_tide', 'deviation'],
color = 'variable',
labels = {'variable': 'legend', 'datetime': 'Date/Time'})
#lables and size
fig.update_layout (title = 'Tide Visualization', font=dict(size=16),
font_family = "Courier New",
title_font_color = "blue",
legend_title_font_color = "red",
width=1500,
height=750,
title_y=1.0,
title_x=0.13,
legend=dict(x=1, y=1, xanchor='right', yanchor='top'))
# Add dropdown
fig.update_layout(
updatemenus=[
dict(
buttons=list([
dict(
args=["type", "scatter"],
label="Luzon",
method="restyle"
),
dict(
args=["type", "bar"],
label="Vizayas",
method="restyle"
),
dict(
args=["type", 'scatter'],
label = 'Mindanao',
method = "restyle"
)
]),
direction="down",
),
]
)
#add time
fig.update_layout(
xaxis=dict(
rangeselector=dict(
buttons=list([
dict(count=1,
label="1m",
step="month",
stepmode="backward"),
dict(count=6,
label="6m",
step="month",
stepmode="backward"),
dict(count=8,
label="8m",
step="year",
stepmode="todate"),
dict(count=1,
label="1y",
step="year",
stepmode="backward"),
dict(step="all")
])
),
rangeslider=dict(
visible=True
)
)
)
#exe
fig.show()
data
Expected output:
each region is different data shown.