如何在 R 中的 Plotly 中删除(动画)帧标题?

问题描述 投票:0回答:1

我正在使用 R-plotly 生成散点图,并一直在尝试删除动画帧标题(例如下面示例中的“am:0”)。
我可以删除轴和颜色的图例;如何删除动画帧标题,或者将其设置为某些自定义文本,例如“外国”

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

Plotly scatter in R with axis titles removed

我找不到任何有关删除框架标题的信息。
此外,仅当 cyl 为因素时才会删除图例标题。

r plotly
1个回答
0
投票

将此添加到您的代码中:

animation_slider(currentvalue = list(prefix = ""))

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

© www.soinside.com 2019 - 2024. All rights reserved.