我正在尝试在R中创建一个Plotly箱线图,但不想显示异常值。我在Plotly的官方页面上找到了这个链接:https://plot.ly/ggplot2/box-plots/#outliers。
问题在于在他们的网页和我的控制台中,仍然显示异常值。
这是某种 bug 吗?
library(plotly)
set.seed(123)
df <- diamonds[sample(1:nrow(diamonds), size = 1000),]
p <- ggplot(df, aes(cut, price, fill = cut)) +
geom_boxplot(outlier.shape = NA) +
ggtitle("Ignore outliers in ggplot2")
# Need to modify the plotly object and make outlier points have opacity equal
to 0
p <- plotly_build(p)
p$data <- lapply(p$data, FUN = function(x){
x$marker = list(opacity = 0)
return(x)
})
# Create a shareable link to your chart
# Set up API credentials: https://plot.ly/r/getting-started
chart_link = plotly_POST(p, filename="geom_boxplot/outliers")
chart_link
问题在于在他们的网页和我的控制台中,仍然显示异常值。
![在这里输入图片描述](https://istack.dev59.com/eAOAo.webp)
geom_boxplot(outlier.shape = NA)
生成一个没有异常值的箱线图。 - Ufos