Building on this post, I am trying to create two updatemenus in R plotly that would allow to select every possible combination of two factors.
This is what I have done so far:
library(plotly)
X <- data.frame(x = 1:6,
y = 1:6,
z = 1:6,
gender = rep(c("M", "F"), each = 3),
eyes = rep(c("B", "G"), 3))
gg <- ggplot(data = X, aes(x = x, y = y)) +
geom_point(aes(color = z, alpha = interaction(gender, eyes))) +
scale_alpha_manual(values = rep(1, 4))
ggplotly(gg) %>%
layout(
updatemenus = list(
list(y = 1,
buttons = list(
list(method = "restyle",
args = list(list(visible = c(TRUE, TRUE, TRUE, TRUE)), 0:3),
label = "F&M"),
list(method = "restyle",
args = list(list(visible = c(TRUE, TRUE)), c(0, 2)),
label = "F"),
list(method = "restyle",
args = list(list(visible = c(TRUE, TRUE)), c(1, 3)),
label = "M"))),
list(y = .8,
buttons = list(
list(method = "restyle",
args = list(list(visible = c(TRUE, TRUE, TRUE, TRUE)), 0:3),
label = "B&G"),
list(method = "restyle",
args = list(list(visible = c(TRUE, TRUE)), 0:1),
label = "B"),
list(method = "restyle",
args = list(list(visible = c(TRUE, TRUE)), 2:3),
label = "G")))
)
)
)
The data:
# x y z gender eyes
# 1 1 1 M B
# 2 2 2 M G
# 3 3 3 M B
# 4 4 4 F G
# 5 5 5 F B
# 6 6 6 F G
This is the output, which does not work at all:
Edit
For instance, if F and B are selected, I would expect only a single data point to be displayed, namely (5, 5).
When you created this plotly object, plotly divided it into five traces. So when you wanted to use visibility, you needed to address each of these traces. If you have any questions, let me know!
I used gg1 to find five traces and what was in each of these traces. You could look at gg1 in the source pane or plotly_json().
Typically (not always!), you'll find the traces at gg1$x$data where gg1 is the plotly object.
There are five traces. For each args, each trace needs a T or F for visibility.
The first trace only contains (5, 5), that's F B
The second trace contains (1, 1) and (3, 3); those are both M B
The third trace contains (4, 4) and (6, 6); those are both F G
The fourth trace contains (2, 2); that's M G
The fifth trace contains the color gradient that all traces use
Here's the code:
gg1 = plotly_build(gg)
ggplotly(gg) %>%
layout(
updatemenus = list(
list(y = 1,
buttons = list(
list(method = "restyle",
args = list("visible", as.list(unlist(rep(T, 5)))),
label = "F&M"),
list(method = "restyle",
args = list("visible", list(T, F, T, F, T)),
label = "F"),
list(method = "restyle",
args = list("visible", list(F, T, F, T, T)),
label = "M")
) # end button
), # end first button list
list(y = .8,
buttons = list(
list(method = "restyle",
args = list("visible", as.list(unlist(rep(T, 5)))),
label = "B&G"),
list(method = "restyle",
args = list("visible", list(T, T, F, F, T)),
label = "B"),
list(method = "restyle",
args = list("visible", list(F, F, T, T, T)),
label = "G")
) # end button
) # end second menu list
) # end updatemenus
) # end layout
Update
From our comments, I do not believe that it's possible at this time to use updatemenus style buttons that interact with each other.
Related
this is my dataframe :
artists <- c("Black Waitress", "Black Pumas")
tee_x<- c(20, 0)
tee_y <- c(3, 18)
tee_z <- c (30,0)
tee_t <- c(0,35)
data2 <- data.frame(artists, tee_x, tee_y,tee_t)
And this is what I am trying to create :
fig <- plot_ly(data=data2, x = ~artists, y = ~tee_x, type = 'bar', name = 'tee_x')
fig <- fig %>% add_trace(y = ~tee_y, name = 'tee_y')
fig <- fig %>% add_trace(y = ~tee_t, name = 'tee_t')
fig <- fig %>% layout(yaxis = list(title = 'Count'), barmode = 'group',
updatemenus = list(
list(
y = 0.8,
buttons = list(
list(method = "restyle",
args = list("x", list(data2[c(1),(2:4)])),
label = "Black Waitress"),
list(method = "restyle",
args = list("x", list(data2[c(2),(2:4)])),
label = "Black Pumas")))
))
fig
I am trying to create a grouper barplot in plotly which shows, for each artist the number of tees they sold and their type. I am also trying to create buttons so that you can look at individual artists instead of both of them. However it is not working and I have no clue how to solve the problem.
Thank you
EDIT :
I have been also trying this way
product <- c("tee_X","tee_y","tee_t")
artists <- c("Black Waitress", "Black Pumas")
Black_Waitress<- c(20, 0, 0)
Black_Pumas <- c(3, 18, 0)
tee_z <- c (30,0)
tee_t <- c(0,35)
data2 <- data.frame(product, Black_Waitress, Black_Pumas)
show_vec = c()
for (i in 1:length(artists)){
show_vec = c(show_vec,FALSE)
}
get_menu_list <- function(artists){
n_names = length(artists)
buttons = vector("list",n_names)
for(i in seq_along(buttons)){
show_vec[i] = TRUE
buttons[i] = list(list(method = "restyle",
args = list("visible", show_vec),
label = artists[i]))
print(list(show_vec))
show_vec[i] = FALSE
}
return_list = list(
list(
type = 'dropdown',
active = 0,
buttons = buttons
)
)
return(return_list)
}
print(get_menu_list(artists))
fig <- plot_ly(data=data2, x = ~product, y = ~Black_Waitress, type = 'bar')
fig <- fig %>% add_trace(y = ~Black_Pumas)
fig <- fig %>% layout(showlegend = F,yaxis = list(title = 'Count'), barmode = 'group',
updatemenus = get_menu_list(artists))
fig
However the problem is that when I choose an artist in the dropdown menu I want to be shown ONLY his/her products (in other words I would like to get rid of the 0 values dynamically) Is this possible?
Without the 0 Values and Initially Blank Plot
Essentially, you need to add a trace with no data. Additionally, since visibility settings were defined, all of that requires updating (because there are more traces now).
This can be further customized, of course. Here's a basic version of what I think you're looking for.
plot_ly(data = data3, x = ~artists, y = 0, type = "bar", color = ~tees,
visible = c(T, T, T)) %>%
add_bars(y = ~values, split = ~artists, # visibility F for all here
legendgroup = ~tees, name = ~tees, visible = rep(F, times = 4),
color = ~tees) %>%
layout(
yaxis = list(title = "Count"), barmode = "group",
updatemenus = list(
list(y = .8,
buttons = list(
list(method = "restyle", # there are 7 traces now; 3 blank
args = list(list(visible = c(F, F, F, F, T, F, T))),
label = "Black Waitress"),
list(method = "restyle",
args = list(list(visible = c(F, F, F, T, F, T, F))),
label = "Black Pumas")))))
Without the 0 Values
By your request, here is a version where the zero values are removed. First, I filtered the data for the non-zero values. This changed the number of traces from 6 to 4, so that needed to be accounted for in the areas where visibility is declared.
In this version, I only commented where there was something that changed from my original answer.
library(plotly)
library(tidyverse)
artists <- c("Black Waitress", "Black Pumas")
tee_x <- c(20, 0)
tee_y <- c(3, 18)
# tee_z <- c(30,0)
tee_t <- c(0,35)
data2 <- data.frame(artists, tee_x, tee_y, tee_t)
data3 <- pivot_longer(data2, col = starts_with("tee"),
names_to = "tees", values_to = "values") %>%
filter(values != 0) # <----- filter for non-zeros
plot_ly(data = data3, x = ~artists, y = ~values, split = ~artists,
legendgroup = ~tees, name = ~tees,
visible = rep(c(F, T), times = 2), # <---- 4 traces
color = ~tees, type = "bar") %>%
layout(
yaxis = list(title = "Count"), barmode = "group",
updatemenus = list(
list(y = .8,
buttons = list(
list(method = "restyle", # 4 traces
args = list(list(visible = c(F, T, F, T))),
label = "Black Waitress"),
list(method = "restyle", # 4 traces
args = list(list(visible = c(T, F, T, F))),
label = "Black Pumas")))))
With the 0 Values
I think it will be a lot easier to use visibility than trying to change out the data. If you wanted to see one artist at a time and use the dropdown to switch between the groups, this works.
First, I rearranged the data to make this easier. When I plotted it, I used split, so that the traces were split by the values on the x-axis, along with the colors. The traces are ordered artist 1, tee_t, artist 2, tee_t... and so on. When using visibility, you need the method restyle (because it's a trace attribute) and a declaration of true or false for each trace.
library(tidyverse)
library(plotly)
data3 <- pivot_longer(data2, col = starts_with("tee"),
names_to = "tees", values_to = "values")
plot_ly(data = data3, x = ~artists, y = ~values, split = ~artists,
legendgroup = ~tees, name = ~tees, visible = rep(c(F, T), times = 3),
color = ~tees, type = "bar") %>%
layout(
yaxis = list(title = "Count"), barmode = "group",
updatemenus = list(
list(y = .8,
buttons = list(
list(method = "restyle",
args = list(list(visible = c(F, T, F, T, F, T))),
label = "Black Waitress"),
list(method = "restyle",
args = list(list(visible = c(T, F, T, F, T, F))),
label = "Black Pumas")))))
I am trying to have a dropdown button within plotly that enables to use different columns of my dataframe for traces to be drawn. However, switching from the first trace to another, arbitrary values gets plotted (not sure what values plotly uses after the first change, but they don't match the dataframe values), the legend gets screwed up (colors are not unique anymore, labels are out of order, not all of the values are shown on the legend, etc.). You can see the plot in action at the link below on R-pubs.
https://rpubs.com/Mdoubledash/testplotlydropdown
What do I mean by not the right traces are drawn? Simply switching to A2 and going back to A1, you see that the plot looks different from the first render and there are duplicated colors/labels on the plot and the legend.
Here's the code I have used (see the reproducible data at the bottom). Here, I am adding 7 traces and then within the layout argument I assign these 7 traces to the dropdown button.
ex_df %>%
plot_ly(x = ~Date, color = ~Model) %>%
add_lines(y = ~`A1`) %>%
add_lines(y = ~`A2`, visible = F) %>%
add_lines(y = ~`A3`, visible = F) %>%
add_lines(y = ~`B1`, visible = F) %>%
add_lines(y = ~`B2`, visible = F) %>%
add_lines(y = ~`C1`, visible = F) %>%
add_lines(y = ~`C2`, visible = F) %>%
layout(
title = "Plotly Dropdown Menus",
xaxis = list(domain = c(1, 1)),
yaxis = list(title = "Value"),
updatemenus = list(
list(y = 10,
buttons = list(
list(method = "restyle",
args = list("visible", list(T, F, F, F, F, F, F)),
label = "A1"),
list(method = "restyle",
args = list("visible", list(F, T, F, F, F, F, F)),
label = "A2"),
list(method = "restyle",
args = list("visible", list(F, F, T, F, F, F, F)),
label = "A3"),
list(method = "restyle",
args = list("visible", list(F, F, F, T, F, F, F)),
label = "B1"),
list(method = "restyle",
args = list("visible", list(F, F, F, F, T, F, F)),
label = "B2"),
list(method = "restyle",
args = list("visible", list(F, F, F, F, F, T, F)),
label = "C1"),
list(method = "restyle",
args = list("visible", list(F, F, F, F, F, F, T)),
label = "C2")
)
)
)
)
The code runs fine, and looks OK with the first render.
Example Dataset:
#dput(ex_df)
ex_df <- structure(list(Model = c("M_0", "M_1", "M_2", "M_3", "M_4", "M_5",
"M_0", "M_1", "M_2", "M_3", "M_4", "M_5",
"M_0", "M_1", "M_2", "M_3", "M_4", "M_5"),
Date = structure(c(1630512000, 1630512000, 1630512000,
1630512000, 1630512000, 1630512000,
1630512900, 1630512900, 1630512900,
1630512900, 1630512900, 1630512900,
1630513800, 1630513800, 1630513800,
1630513800, 1630513800, 1630513800),
tzone = "", class = c("POSIXct", "POSIXt")),
A1 = c(4.3924, 2.77967, 3.23016, 3.23016, 4.3924, 4.3924,
4.45712, 2.8175, 3.27791, 3.27789, 4.45715, 4.43708,
4.87661, 3.10666, 3.61006, 3.61005, 4.8779, 4.79372),
A2 = c(0.19052, 0.19052, 0.19052, 0.19052, 0.19052, 0.19052,
0.43156, 0.43156, 0.43156, 0.43163, 0.43156, 0.43156,
0.6055, 0.6055, 0.6055, 0.60551, 0.6055, 0.6055),
A3 = c(NA, 4.33173, 3.88124, 3.88124, 2.719, 2.719,
NA, 4.33173, 3.96342, 3.9293, 2.719, 2.719,
NA, 4.34133, 2.46357, 4.12238, 2.719, 2.719),
B1 = c(13.03056, 11.41784, 11.86833, 11.86833, 13.03056,13.03056,
13.02643, 11.41376, 11.86428, 11.86428,13.02643, 13.02643,
13.01181, 11.3972, 11.84812, 11.84812, 13.01181, 13.01093),
B2 = c(15.90011, 18.61912, 14.73789, 18.61912, 18.6191, 18.6191,
20.56435, 21.78546, 20.17156, 21.78857, 21.78544, 21.78544,
18.05423, 19.96631, 17.51721, 19.96667, 19.96629, 19.96629),
C1 = c(116.84061, 116.84061, 120.72184, 116.84061, 116.84061, 116.84062,
35.50683, 35.50684, 36.85026, 35.56428, 35.50684, 35.50679,
162.67923, 162.67924, 168.46906, 162.67662, 162.67924, 162.67929),
C2 = c(106.3359, 106.3359, 106.33588, 106.33589, 106.3359, 106.33603,
-24.20234, -24.20234, -25.43058, -24.17748, -24.20234, -24.20229,
345.84013, 345.84011, 332.59987, 345.83915, 345.84011, 345.84026)),
class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, -18L))
The reason you're not seeing what you expect is because of how Plotly handles your data. Typically, Plotly will make a separate trace for each color. You created 7 traces; you have 6 unique values in Model. You need around 42 T or F, but around doesn't work.
How many traces?
plt <- ex_df %>%
plot_ly(x = ~Date, color = ~Model) %>%
add_lines(y = ~A1) %>%
add_lines(y = ~A2, visible = F) %>%
add_lines(y = ~A3, visible = F) %>%
add_lines(y = ~B1, visible = F) %>%
add_lines(y = ~B2, visible = F) %>%
add_lines(y = ~C1, visible = F) %>%
add_lines(y = ~C2, visible = F)
plt <- plotly_build(plt)
length(plt$x$data)
# [1] 41
To determine which column doesn't have all colors, sometimes you can look at the name and legendgroup for the traces. However, when I looked, there were no legendgroup designations. The Model is the trace name.
You can look at this like so:
x <- invisible(lapply(1:length(plt$x$data),
function(i){
plt$x$data[[i]]$name
})) %>% unlist()
table(x)
# x
# M_0 M_1 M_2 M_3 M_4 M_5
# 6 7 7 7 7 7
I tried a few more things to determine which trace was missing a color.
funModeling::df_status(ex_df)
# A3 as has NA's; that's probably the one that's missing a color
ex_df[ , c(1, 5)] %>% na.omit() %>% select(Model) %>% unique()
# # A tibble: 5 × 1
# Model
# <chr>
# 1 M_1
# 2 M_2
# 3 M_3
# 4 M_4
# 5 M_5 # A3 is missing M_0
The layout, armed with the right info.
plt %>%
layout(
title = "Plotly Dropdown Menus",
xaxis = list(domain = c(1, 1)),
yaxis = list(title = "Value"),
updatemenus = list(
list(y = 10,
buttons = list(
list(method = "restyle",
args = list("visible", c(rep(T, 6), rep(F, 35))),
label = "A1"),
list(method = "restyle",
args = list("visible", c(rep(F, 6), rep(T, 6), rep(F, 29))),
label = "A2"),
list(method = "restyle",
args = list("visible", c(rep(F, 12), rep(T, 5), rep(F, 24))),
label = "A3"),
list(method = "restyle",
args = list("visible", c(rep(F, 17), rep(T, 6), rep(F, 18))),
label = "B1"),
list(method = "restyle",
args = list("visible", c(rep(F, 23), rep(T, 6), rep(F, 12))),
label = "B2"),
list(method = "restyle",
args = list("visible", c(rep(F, 33), rep(T, 6), rep(F, 6))),
label = "C1"),
list(method = "restyle",
args = list("visible", c(rep(F, 35), rep(T, 6))),
label = "C2")
) # end buttons list
)) # end updatemenus list
) # end layout
Looks good.
I ran another plot just to check.
ex_df %>%
plot_ly(x = ~Date, color = ~Model) %>%
add_lines(y = ~C2) %>%
layout(
title = "Plotly Dropdown Menus",
xaxis = list(domain = c(1, 1)),
yaxis = list(title = "Value"))
I am trying to use a dropdown menu to plot a subsample of a dataset using the dropdown menu from plotly in R.
This is what I have so far (based on this answer) without sucess:
library(data.table)
library(ggplot2)
library(plotly)
X <- data.table(xcoord = 1:10, ycoord = 1:10)
Z <- X[xcoord < 5]
gg <- ggplot(X, aes(x = xcoord, y = ycoord)) + geom_point()
ggplotly(gg) %>%
layout(updatemenus = list(
list(buttons = list(
list(method = "restyle",
args = list(list("x", list(X$xcoord)),
list("y", list(X$xcoord))),
label = "X"),
list(method = "restyle",
args = list(list("x", list(Z$xcoord)),
list("y", list(Z$ycoord))),
label = "Z")
))
))
Found the solution: had to use named lists instead.
ggplotly(gg) %>%
layout(updatemenus = list(
list(buttons = list(
list(method = "restyle",
args = list(list(x = list(X$xcoord)),
list(y = list(X$xcoord))),
label = "X"),
list(method = "restyle",
args = list(list(x = list(Z$xcoord)),
list(y = list(Z$ycoord))),
label = "Z")
))
))
I'm creating a boxplot with dropdown options for the variable that gets plotted on the y axis. The data has 4 "people", and each observation has a type A or B. For each person 1:4, the chart plots bars for the observations A and B (example: https://plot.ly/r/box-plots/#grouped-box-plots).
I'm able to create it, but once I change the dropdown the groupings all get messed up. Here's example code:
library(plotly)
set.seed(123)
x <- rep(1:4, 6)
y1 <- rnorm(24, 5, 2)
y2 <- rnorm(24, 2, 5)
type <- rep(c("A", "A", "B", "B", "B", "B", "A", "A"), 3)
df <- data.frame(x, y1, y2, type)
p <- plot_ly(df, x = ~x) %>%
add_boxplot(y = ~y1, color = ~type, name = "First") %>%
add_boxplot(y = ~y2, color = ~type, name = "Second", visible = F) %>%
layout(
boxmode = "group",
title = "On/Off Box Plot",
xaxis = list(domain = c(0.1, 1)),
yaxis = list(title = "y"),
updatemenus = list(
list(
y = 0.8,
buttons = list(
list(method = "restyle",
args = list("visible", list(TRUE, FALSE)),
label = "y1"),
list(method = "restyle",
args = list("visible", list(FALSE, TRUE)),
label = "y2")))
)
)
p
The dropdown starts with y1 and looks exactly how I'd like, but changing the dropdown regroups the data and changing back to y1 doesn't get back to the original graph.
Here's what's happening to the groupings: After changing the dropdown, y1 groups all type "A" with y1 and y2 plotted next to each other. Option y2 does the same but uses type "B" data. I only want y1 data for both types A/B (like the original graph).
I'm guessing the ' boxmode = "group" ' line is getting lost during the switches, but I can't get it to work. Does anyone know how to maintain the groupings based on type? Thank you.
updatemenus should be length 4, because there are actually 4 traces (2 visible at a time). Note that for groups, each legend item has a corresponding trace. Unfortunately R's automatic repeating of vectors obscures this.
ie, the value for updatemenus should be:
updatemenus = list(
list(
y = 0.8,
buttons = list(
list(method = "restyle",
args = list("visible", list(TRUE, TRUE, FALSE, FALSE)),
label = "y1"),
list(method = "restyle",
args = list("visible", list(FALSE, FALSE, TRUE, TRUE)),
label = "y2")))
)
I am not sure if this is possible, but here is what I would like to do. I would like to update the data in a plotly plot by selecting from a dropdown menu.
As a simple example, let's assume I have a data frame
df <- data.frame(x = runif(200), y = runif(200), z = runif(200))
from which I use df$x and df$y in a scatter plot. Two scenarios of data manipulation I would like to achieve using a dropdown:
Replace df$y with df$z
Plot only the first n values of df$x and df$y
I looked at the following two examples, which I can easily reproduce:
https://plot.ly/r/dropdowns/
However, I have no idea how to pass the information regarding the data to be plotted based on the dropdown selection. For scenario 2 e.g. I have tried it with args = list("data", df[1:n,]) which did not work.
For scenario 1 the (only?) way to go (according to the examples) seems to be hiding/showing the traces respectively. Is that the only way for scenario 2 as well?
Any alternative ideas?
Update 1: Add reproducible example
So here is an example which achieve what I would like in scenario 1.
require(plotly)
df <- data.frame(x = runif(200), y = runif(200), z = runif(200))
Sys.setenv("plotly_username"="xxx") #actual credentials replaced
Sys.setenv("plotly_api_key"="xxx") #actual credentials replaced
p <- plot_ly(df, x = df$x, y = df$y, mode = "markers", name = "A", visible = T) %>%
add_trace(mode = "markers", y = df$z, name = "B", visible = T) %>%
layout(
title = "Drop down menus - Styling",
xaxis = list(domain = c(0.1, 1)),
yaxis = list(title = "y"),
updatemenus = list(
list(
y = 0.7,
buttons = list(
list(method = "restyle",
args = list("visible", list(TRUE, TRUE)),
label = "Show All"),
list(method = "restyle",
args = list("visible", list(TRUE, FALSE)),
label = "Show A"),
list(method = "restyle",
args = list("visible", list(FALSE, TRUE)),
label = "Show B")))
))
plotly_POST(p)
Result here: https://plot.ly/~spietrzyk/96/drop-down-menus-styling/
This is based on the example from https://plot.ly/r/dropdowns/
However, I am wondering if one could pass the data to be plotted instead of triggering changes to the visible property of individual traces.
The one thing I tried was the following:
p <- plot_ly(df, x = df$x, y = df$y, mode = "markers", name = "A", visible = T) %>%
layout(
title = "Drop down menus - Styling",
xaxis = list(domain = c(0.1, 1)),
yaxis = list(title = "y"),
updatemenus = list(
list(
y = 0.7,
buttons = list(
list(method = "restyle",
args = list("y", df$y),
label = "Show A"),
list(method = "restyle",
args = list("y", df$z),
label = "Show B")))
))
Result here: https://plot.ly/~spietrzyk/98/drop-down-menus-styling/
This approach cannot work, as the data from df$z is not posted to the grid (https://plot.ly/~spietrzyk/99/).
So I was wondering is there anyway to manipulate the data to be plotted based on dropdown selection, beyond plotting all traces and than switching the visible property by dropdown selections.
Is this what you were after?
require(plotly)
df <- data.frame(x = runif(200), y = runif(200), z = runif(200))
p <- plot_ly(df, x = ~x, y = ~y, mode = "markers", name = "A", visible = T) %>%
layout(
title = "Drop down menus - Styling",
xaxis = list(domain = c(0.1, 1)),
yaxis = list(title = "y"),
updatemenus = list(
list(
y = 0.7,
buttons = list(
list(method = "restyle",
args = list("y", list(df$y)), # put it in a list
label = "Show A"),
list(method = "restyle",
args = list("y", list(df$z)), # put it in a list
label = "Show B")))
))
p
On the top of #jimmy G's answer.
You can automatically create the buttons so that you don't have to manually specify every single variable you want in the plot.
library(plotly)
df <- data.frame(x = runif(200), y = runif(200), z = runif(200), j = runif(200), k = rep(0.7, 200), i = rnorm(200,0.6,0.05))
create_buttons <- function(df, y_axis_var_names) {
lapply(
y_axis_var_names,
FUN = function(var_name, df) {
button <- list(
method = 'restyle',
args = list('y', list(df[, var_name])),
label = sprintf('Show %s', var_name)
)
},
df
)
}
y_axis_var_names <- c('y', 'z', 'j', 'k', 'i')
p <- plot_ly(df, x = ~x, y = ~y, mode = "markers", name = "A", visible = T) %>%
layout(
title = "Drop down menus - Styling",
xaxis = list(domain = c(0.1, 1)),
yaxis = list(title = "y"),
updatemenus = list(
list(
y = 0.7,
buttons = create_buttons(df, y_axis_var_names)
)
))
p
Hope you find it useful.