You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 0fig<- plotly_build(p)
fig$data<- lapply(fig$data, FUN=function(x){
x$marker=list(opacity=0)
return(x)
})
fig
it should be
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 0fig<- plotly_build(p)
fig$x$data<- lapply(fig$x$data, FUN=function(x){
x$marker=list(opacity=0)
return(x)
})
fig
Note the difference fig$x$data instead of fig$data otherwise this won't remove the outliers.
The text was updated successfully, but these errors were encountered:
In this explanation for how to implement geom_boxplot with plotly (https://plotly.com/ggplot2/box-plots/#outliers) there is a mistake in the function used.
Currently the code example reads like this:
it should be
Note the difference
fig$x$data
instead offig$data
otherwise this won't remove the outliers.The text was updated successfully, but these errors were encountered: