Hi, I am trying to create a scatterplot that uses dropdown for filtering.
library(plotly)
plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length, mode = 'markers', visible = T) %>%
layout(
title = "Iris Dropdown",
updatemenus = list(
list(
buttons = list(
list(method = 'restyle',
args = list(iris$Species == "setosa", list(iris$Species =='setosa')),
label = "Setosa"),
list(method = 'restyle',
args = list("iris$Species" == "versicolor", list(iris$Species =='versicolor')),
label = "Versicolor"),
list(method = 'restyle',
args = list(iris$Species == 'virginica', list(iris$Species =='virginica')),
label = "Virginica")
))))
For the most part, it works except the dropdown. I did try reading through the examples (URL) but it was for changing a chart type. My understanding is that the key to dropdown is the args = list(x,y) . My understanding is the x is what to show, and y is the condition.
Please advise.