Removing outliers from the drawer and schedule

I am trying to create a plotly boxplot in R that does not show outliers, and I found this link on the official plotly page: https://plot.ly/ggplot2/box-plots/#outliers

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 

The problem is that their webpage and my console are still showing outliers. enter image description here It's some kind of mistake?

+6
source share
2 answers

It seems a typo. Perhaps this example has not been updated to take into account some changes in the structure of the object. After calling p <- plotly_build(p) we noticed that there is no p$data , but there is p$x$data . So, changing the lapply call to the following:

 p$x$data <- lapply(p$x$data, FUN = function(x){ x$marker = list(opacity = 0) return(x) }) 

makes everything work as you like:

enter image description here

+1
source

The decision on how to make emissions transparent when using jitter was posted here:

https://community.plot.ly/t/ggplotly-ignoring-geom-boxplot-outlier-parameters/2247/2

0
source

Source: https://habr.com/ru/post/1266925/


All Articles