I'm using R-plotly to produce a scatterplot and have been trying to remove the animation frame title (e.g. "am:0" in the example below).
I can remove the legends for axis and colour; how can I remove animation frame title, or alternatively set it to some custom text e.g. "Foreign"
library(tidyverse)
library(plotly)
df <- mtcars %>% mutate(cyl = as_factor(cyl))
scatter_plot <- plot_ly(data = df, x = ~wt, y = ~mpg, type = 'scatter', mode = 'markers', color = ~cyl, frame = ~am) %>%
layout(xaxis = list(title = " "), yaxis = list(title = " "), legend=list(title= list(text = " ")))
scatter_plot
I can't find any information on removing the frame title.
In addition, the legend title is only removed when cyl is a factor.
See here: Change the 'Frame' Label in Plotly Animation @ismirsehregal's answer:
First approach:
Add this to your code: animation_slider(currentvalue = list(prefix = ""))
. This will remove am:
library(tidyverse)
library(plotly)
df <- mtcars %>% mutate(cyl = as_factor(cyl))
scatter_plot <- plot_ly(data = df, x = ~wt, y = ~mpg, type = 'scatter', mode = 'markers', color = ~cyl, frame = ~am) %>%
layout(xaxis = list(title = " "),
yaxis = list(title = " "),
legend=list(title= list(text = " "))) %>%
animation_slider(currentvalue = list(prefix = ""))
scatter_plot
Second approach:
If we want to remove also 0 and 1, then we can set animation_slider(currentvalue = list(visible = FALSE))
:
library(tidyverse)
library(plotly)
df <- mtcars %>% mutate(cyl = as_factor(cyl))
scatter_plot <- plot_ly(data = df, x = ~wt, y = ~mpg, type = 'scatter', mode = 'markers', color = ~cyl, frame = ~am) %>%
layout(xaxis = list(title = " "),
yaxis = list(title = " "),
legend=list(title= list(text = " "))) %>%
animation_slider(currentvalue = list(visible = FALSE))
scatter_plot