I just changed the 'at' argument and added an 'xlim' option.
boxplot(len ~ dose, data = ToothGrowth, boxwex = 0.25, at = 1:3, subset = which(supp == "VC"), col = "yellow", main = "Guinea Pigs' Tooth Growth", xlab = "Vitamin C dose mg", ylab = "tooth length", xlim=c(1, 6), ylim=c(0, 35), yaxs="i") abline(v=3.5) boxplot(len ~ dose, data = ToothGrowth, add = TRUE, boxwex = 0.25, at = 1:3 + 3, subset = which(supp == "OJ"), col = "orange") legend("bottomright", c("Ascorbic acid", "Orange juice"), fill = c("yellow", "orange")) Regards, Adai cathelf wrote:
Thank you for your guys reply for my previous question. But I got one more question about the boxplot. With the code in the R-help: boxplot(len ~ dose, data = ToothGrowth, boxwex = 0.25, at = 1:3 - 0.2, subset = supp == "VC", col = "yellow", main = "Guinea Pigs' Tooth Growth", xlab = "Vitamin C dose mg", ylab = "tooth length", ylim = c(0, 35), yaxs = "i") boxplot(len ~ dose, data = ToothGrowth, add = TRUE, boxwex = 0.25, at = 1:3 + 0.2, subset = supp == "OJ", col = "orange") legend(2, 9, c("Ascorbic acid", "Orange juice"), fill = c("yellow", "orange")) I got 6 boxplots, which is ordered as "0.5, 0.5, 1, 1, 2, 2" How can I reorder the 6 boxplots as "0.5, 1, 2, 0.5, 1, 2"? Thank you very much!
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.