0

I'm trying to create a box plot without outliers

I have tried with ggplot's outlier.shape but the result was not satisfactory as it hides most part of the Whiskers because of the different range in Resolved_Hour column across priority. Tweaking the cartesian coordinates further elongates the Whisker's

a <- ggplot(data, aes(x=priority,y=Resolved_Hour,color = priority))+
  geom_boxplot(outlier.shape = NA)+
  coord_cartesian(ylim = quantile(data$Resolved_Hour,c(0.25,0.75),na.rm = T))

ggplotly(a)

Eg:

enter image description here

The basic box plot from graphics library helped me plot without outliers using outline = F

boxplot(Resolved_Hour ~ priority,data = data,horizontal=TRUE,axes=TRUE,outline=FALSE,col = "bisque")

But I couldn't add interactivity to this plot as

a <- boxplot(Resolved_Hour ~ priority,data = data,horizontal=TRUE,axes=TRUE,outline=FALSE,col = "bisque")

ggplotly(a)

It throws an error as

Error in UseMethod("ggplotly", p) : no applicable method for 'ggplotly' applied to an object of class "list"

The plot is saved as a list as below: enter image description here

Any help is highly appreciated :-) to resolve and plot a better box plot. Thank you.

  • Couldn’t you just remove them from the dataset prior to plotting? – Justin Cocco Dec 29 '20 at 07:07
  • Does this answer your question? [Ignore outliers in ggplot2 boxplot](https://stackoverflow.com/questions/5677885/ignore-outliers-in-ggplot2-boxplot) – Dan Slone Dec 29 '20 at 07:25
  • 1
    In my opinion your issue is not related to ggplot2 vs. base boxplot but is a ggplotly issue instead, i.e. using `outlier.shape=NA` works fine for me in ggplot2 but is ignored by `ggplotly`. – stefan Dec 29 '20 at 09:31

0 Answers0