I would like to add a dropdown menu, where the user can view data only from a specific year (provided in the dataset there are 3 years) - or using any other column.
The goal is to allow the data shown represent all years, but to be flexible and allow the user to deep dive onto one specific year.
I’d recommend taking a look at how some of the slider examples work (like https://plot.ly/python/sliders/#simple-slider-control). The basic approach in this example is to create a separate trace for each year (or whatever grouping you’d like to use), and then the slider steps change which trace is visible.
You should be able to adapt this approach to control the visibility using a dropdown control rather than a slider by moving the
args properties from
Feel free to post a small example if you’d like to work through more of the details.
Hope that helps!
Thanks for your response.
I took a look, and while it might be helpful when trying to slide between years, this doesn’t give the option to accumulate years: if I’m interested in 2016 AND 2017 AND 2019 but NOT 2018, I cannot achieve that with a slider.
I was wondering if something like a Tableau filter exists - where you have a checkbox based on values from one of the columns (see in this link)
I don’t think you’ll be able to accomplish this kind of filtering use case with the built-in Plotly.js widgets. For more advanced use cases you can move to using a
FigureWidget in the Jupyter Notebook (See https://plot.ly/python/figurewidget-app/ for example) or using Dash for a standalone web app (See https://dash.plot.ly/).
Thanks - I’ll look into these options