Boxplots without boxes

Let’s say you have several categories with multiple data points each that you would like to plot as individual points. Even if you have only a single point, the R graphics package will plot a line (without a box for lack of data). Overriding the default setting with e.g. pch = 1 does not help.

R’s boxplot function (or the plot function for that matter) – correctly – generates a boxplot for each category. If you would like to see individual points instead of boxes, the following code snippet could help by using the points function:

# Plot the boxplot as usual, but in white colour to make the boxes invisible, but keep the axes.

boxplot(m$var ~ m$cat, xlab = "Category", ylab = "Variable", border = "white")

# Plot the data again into the same plot and customise the point shape, etc to your liking

points(m$var ~ m$cat, pch = 1)


More fun with boxplots

Here are a few more plotting options for boxplots:

Let’s start plotting the full set
plot(b$mod, b$x)

Plot labels for a subset in full set plot (label all points x < -1)
text(subset(b$mod, b$x < -1), subset(b$x, b$x < -1), subset(b$site, b$x < -1), cex=0.6, pos=4, col="red")

Plot subset with x > -1
plot(subset(b$mod, b$x > -1), subset(b$x, b$x > -1))

Plot horizontal gridlines
grid(nx = NA, ny = NULL)