当我在ggplot2图上使用ggplotly时,将重置ggplot2的某些功能。
代码示例:
p <- db %>% ggplot2(aes(x, y)) +
geom_boxplot(varwidth = TRUE, outlier.shape = NA)
使用ggplotly(p)
时,var.width
参数不起作用,并且圆的异常形状返回。这是ggplolty的固有特性吗?如果是这样,如何在ggplotl2中获得这些选项?
谢谢!
Plotly似乎并没有继承所有ggplot参数。至少可以通过以下线程更改异常值:https://github.com/ropensci/plotly/issues/1114
library(tidyverse)
library(plotly)
p <- iris %>% ggplot(aes(Species, Sepal.Length)) +
geom_boxplot(varwidth = TRUE, outlier.shape = NA)
# Need to modify the plotly object and make outlier points have opacity equal to 0
p <- plotly_build(p)
for(i in 1:length(p$x$data)) {
p$x$data[[i]]$marker$opacity = 0
}
p
异常值已删除。我不确定是否可以将var.width
插入密谋的箱线图中。