Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

R’s `boxplot` function has a lot of useful parameters allowing us to change the behaviour and appearance of the boxplot graphs. In this exercise we will try to use those parameters in order to replicate the visual style of Matlab’s boxplot. Before trying out this exercise please make sure that you are familiar with the following functions: `bxp`, `boxplot`, `axis`, `mtext`

We will be using the same iris dataset which is available in R by default in the variable of the same name – `iris`. The exercises will require you to make incremental changes to the default boxplot style.

Answers to the exercises are available here.

If you obtained a different (correct) answer than those listed on the solutions page, please feel free to post your answer as a comment on that page.

Exercise 1
Make a default boxplot of Sepal.Width stratified by Species.

Exercise 2
Change the range of the y-axis so it starts at 2 and ends at 4.5.

Exercise 3
Modify the boxplot function so it doesn’t draw ticks nor labels of the x and y axes.

Exercise 4
Add notches (triangular dents around the median representing confidence intervals) to the boxes in the plot.

Exercise 5
Increase the distance between boxes in the plot.

Exercise 6
Change the color of the box borders to blue.

Exercise 7
a. Change the color of the median lines to red.
b. Change the line width of the median line to 1.

Exercise 8
a. Change the color of the outlier points to red.
b. Change the symbol of the outlier points to “+”.
c. Change the size of the outlier points to 0.8.

Exercise 9
a. Add the title to the boxplot (try to replicate the style of matlab’s boxplot).
b. Add the y-axis label to the boxplot (try to replicate the style of matlab’s boxplot).

Exercise 10
a. Add x-axis (try to make it resemble the x-axis in the matlab’s boxplot)
b. Add y-axis (try to make it resemble the y-axis in the matlab’s boxplot)
c. Add the y-axis ticks on the other side.

NOTE: You can use `format(as.character(c(2, 4.5)), drop0trailing=TRUE, justify="right")` to obtain the text for y-axis labels.