Reputation: 55
How do I get it so that it returns a box-plot without upper & lower whiskers? When I run this:
a <- ggplot(df1, aes(Name, Values)) +
geom_violin(width = 6, alpha = 0.5, trim = FALSE) +
geom_boxplot(width = 1, fill = "black", colour = "black", alpha = 0.5) +
geom_jitter(size = 1, alpha = 0.5) +
stat_summary(fun = mean, geom = "point", shape = 6, alpha = 0.5) +
theme(panel.grid.major.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank()) +
ggtitle(label = "Title of Plot")
a
I get a boxplot without upper & lower whiskers. However when I run this:
ggplotly(a)
I get a boxplot with upper & lower whiskers. I require the plot to be interactive, but I want to remove the upper & lower whiskers. How would I do this?
Upvotes: 1
Views: 169
Reputation: 18714
Other than starting in Plotly or removing the whiskers in ggplot
, you can change them by modifying the ggplotly
object whiskerwidth
for each type = "box"
trace.
plt <- ggplotly(a) # create a ggplotly object
invisible(lapply(1:length(plt$x$data),
function(k) { # ensure it's a box trace
if(isTRUE(plt$x$data[[k]]$type == "box")) {
plt$x$data[[k]]$whiskerwidth <<- 0 # no width whiskers
}
}))
plt # check out the change
Upvotes: 1