Dropdown Box w/ plotly
Would it be okay to ask questions about using/interacting with Marimo here? I want to make just a simple dropdown that decides what plots i display, but when i choose the value in the dropdown box, the graph only displays for a split second before just dissapearing. I am using plotly plots.
15 Replies
idk why its not working, its just a simple dropdown box that returns the plot global variable
can you try this:
juandice_bar_plot = _fig
instead of mo.ui.plotly(_fig)
it worked.
why tho?
i think
mo.ui.plotly(_fig)
will make dropdown
rerender again and again
you can also set value=Jaundice
in the dropdown
set the default value of the dropdown to that plotly object
i think something is happening inside mo.ui.plotly(_fig)
and this everlasting change will make dropdown
roll back to its defaultyeah that's the assumption that I just came down too, but now my question is how would configure my plotly plot if i cant use the mo.ui.ploty function, nor can use fig.show
i can't figure out how to do this
sorry 🫠
oh
i solve that
you need to implement as below:
and create a mapping:
and display use mapping:
it should work fine 🐌
omg thank you!
i havent even tried touching states, but this will be an amazing segway into it. I appreciate the help!
Hi i'm back again, with another problem when using plotly with marimo, this time im trying to use a box plot with a dropdown and its just printing out the Figure data :/
The same thing is happening for every box_plot, my bar graphs from early are not experiecing any issues though.
My box_plots were fine until i tried configure the color of my graphs using plotly expresses' libary of colors:
- specifically:
After trying to configure the colors, all of my box_plots started printing like that instead of displaying the actual graph
Attempts to Fix:
- literally uninstalled and reinstalled plotly and marimo, the error still persisted
i think you maybe should try this:
don't write them in a single line
maybe it's a problem regarding incorrect markdown format
sadly not the case
It’s possibly we don’t support plotly configuration correctly. We can look into this
Nice suggestion! It's actually possible to do this without using
mo.state
at all, since you don't need cycles and dropdown already stores its value. Here is what I would suggest. (cc @V3)
Thank you for the suggestion! I just got out of work/class so I’ll try the code once I get home!
still appears wrong in the markdown box :/
So, I just tried using a tabs instead of dropdown, and the plots started to show correctly
which is yay, but no clue why dropdown menu doesnt work with box plots
dropdown menu worked with bar plots in a previous segment of this doc