Line plots in dropdown menus

Hi guys ! I would like to know if someone know how can I display lineplots using a dropdown menu. I basically ran the code bellow and it produces a scatter plot for the line part. Thank you !
import plotly.graph_objects as px
import pandas as pd

reading the database

data = pd.read_csv(“tips.csv”)

plot = px.Figure(data=[px.Scatter(
x=data[‘day’],
y=data[‘tip’],
mode=‘markers’,)
])

Add dropdown

plot.update_layout(
updatemenus=[
dict(
buttons=list([
dict(
args=[“type”, “scatter”],
label=“Scatter Plot”,
method=“restyle”
),
dict(
args=[“type”, “bar”],
label=“Bar Chart”,
method=“restyle”
),
dict(
args=[“type”, “line”],
label=“Line Plot”,
method=“restyle”
),
dict(args = [“type”, “box”],
label = “Box”,
method = “restyle”
),
dict(args = [“type”, “violin”],
label = “Violin”,
method = “restyle”
)
]),
direction=“down”,
),
]
)
plot.show()

Hey @Loann, welcome to our forum!

I’m not sure I understand exactly what you want to achieve. This code is not using any Streamlit at all, but is using Plotly. Have you tried adding st.plotly_chart(plot) at the very end? Or do you want to achieve the same result as Plotly but using Streamlit?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.