I am new to ggplot (aka ggplot2) and have noticed that for some reason it always makes my boxplots so large that a single box dominates the entire plot. The plot below was generated from the ToothGrowth dataset using the following code:
bp = ggplot(ToothGrowth, aes(x=dose, y=len, color = dose)) + geom_boxplot() + theme(legend.position = "none")
bp
In case you haven't got the ToothGrowth dataset for some reason (its in the library "datasets"), the variables len and dose are both numeric. len has three discreet values, (0.5, 1.0, 2.0) while dose is continuous from approximately 4-30. I expect my boxplot to show three different boxes for the three discreet values of len
I suspect this is caused by some weird graphics settings but I have no idea where to begin my search. Has anyone else run into this kind of problem?
width
parameter controls how wide the boxes are relative to the rest of the plot.ggplot(ToothGrowth, aes(x=dose, y=len, group=dose)) + geom_boxplot(width=0.2)
. – eipi10ggplot(ToothGrowth, aes(x="", y=len)) + geom_boxplot(width=0.5) + labs(x="")
– eipi10