ggplot 到 ggplotly 不适用于自定义 geom_boxplot 宽度

Joe*_*lle 5 r ggplot2 boxplot plotly ggplotly

当我尝试在 ggplot 中为箱线图设置自定义宽度时,它工作正常:

p=ggplot(iris, aes(x = Species,y=Sepal.Length )) + geom_boxplot(width=0.1)
Run Code Online (Sandbox Code Playgroud)

但是当我尝试使用 ggplotly 时,宽度(和 hjust)是默认的:

p %>% ggplotly()
Run Code Online (Sandbox Code Playgroud)

我做错了什么或者这是 ggplotly 中的错误?

use*_*748 5

您可以使用布局来设置 boxgap:

library(ggplot2)
library(plotly)

p <- ggplot(iris, aes(x = Species,y=Sepal.Length )) +
   geom_boxplot()

ggplotly(p) %>% plotly::layout(boxgap=0.9)
Run Code Online (Sandbox Code Playgroud)

另请参阅https://plot.ly/python/box-plots/#Grouped-Box-Plot