Open
Description
If I create a boxplot in ggplot2 and convert it using ggplotly command, the outliers are outlined in black.
Here is a simple example:
library(ggplot2)
library(plotly)
p <- ggplot(mpg, aes(class, hwy))
g <- p + geom_boxplot(aes(colour = "red"))
ggplotly(g)
whereas plotly would show this chart:
Is this something that can be fixed?
Activity
jonocarroll commentedon Nov 17, 2017
This persists even when the outliers should be discarded, in the examples also
petehilljnr commentedon Apr 30, 2018
I managed to set the opacity property of the outliers using the code below. This seems to work for the faceted charts I have tried so far also.
jonocarroll commentedon May 1, 2018
The replacement
lapply
code is then(note
p$x$data
rather thanp$data
). I'm happy to PR this to the documentation if someone can point to the source.dmattek commentedon Jul 10, 2018
The problem is that when you also have
geom_jitter
in the plot (in addition togeom_boxplot
), thelapply
part will remove all the points. Is there a way to selectively remove outliers that belong togeom_boxplot
only?ningjingzhiyuan507 commentedon Jul 19, 2018
p$x$data <- lapply(p$x$data, FUN = function(x){ x$marker$line$width = 0 return(x) })
modify marker$line$color
brshallo commentedon Feb 25, 2019
You can use the code above and just index to the layer you want to remove, e.g. say the boxplot outliers are on the first layer.
kojisposts commentedon Jul 12, 2019
Hi! Just wanted to bring this issue to your attention again, as none of the workarounds mentioned above seem to be working (and aren't working in the documentation either)!
(There's also an interesting phenomenon where, for coloured barplots, the most extreme outliers are coloured with black outlines, but closer to the barplot, they're black with coloured outlines, i.e. the reverse.)
cpsievert commentedon Jul 12, 2019
There's a WIP here #1514 that fixes this issue, feel free to test it out and let me know if you run into problems.
jcoronel25 commentedon Dec 12, 2019
I didn't see the solution being mentioned #1514 on the last release. I was to get the visual I wanted by altering the lapply function to filter only layer that are type == "box"
isaaczhao23 commentedon Feb 26, 2020
This will do the trick for the original question coloring outliers! Plotly differentiates outliers from extreme outliers. We go under the hood and override all outlier colors manually.
10 remaining items