Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ggplot increase distance between boxplots

Tags:

r

ggplot2

boxplot

How can I avoid attached box-plots? Thank you

ggplot(df, aes(x=factor(time), y=val, fill=ID))+
geom_boxplot()+
scale_fill_manual(values=c(WT="goldenrod3", KO="steelblue"))

enter image description here

like image 768
Al14 Avatar asked Sep 01 '15 23:09

Al14


People also ask

How do I change the size of a boxplot in R?

The font size of the main title of boxplot can be changed by defining the font size value using par(cex. main=”size”), here size value can be changed based on our requirement. This needs to be done before creating the boxplot, otherwise, there will be no effect on the size of the main title.

Does Ggplot boxplot show median or mean?

A boxplot summarizes the distribution of a continuous variable and notably displays the median of each group.

What does boxplot in Ggplot show?

The boxplot compactly displays the distribution of a continuous variable. It visualises five summary statistics (the median, two hinges and two whiskers), and all "outlying" points individually.

How do you space a box plot in Excel?

Right-click one of the boxes on the chart and choose Format Data Series to open the Format Data Series pane. Increase or decrease the Gap Width to control the spacing of the gap between the boxes.


1 Answers

Look at position_dodge, the width argument can help with spacing

mtcars$sep <- 1:2  # a factor

ggplot(mtcars, aes(x=factor(carb), y=mpg, fill=factor(sep))) +
  geom_boxplot(position=position_dodge(width=0.8))
like image 163
Rorschach Avatar answered Sep 29 '22 10:09

Rorschach