Avatar
Avatar

Reputation: 63

Bold boxplot labels in R

Does anybody know how to embolden the x and y axis labels ("Single sample" and "Value axis") in an R boxplot?

This is what my boxplot looks like: http://img822.imageshack.us/img822/331/23807704.png

Upvotes: 6

Views: 21574

Answers (1)

Gavin Simpson
Gavin Simpson

Reputation: 174908

Using this example data:

dat <- data.frame(values = c(rnorm(100, mean = 1), rnorm(100, mean = 3),
                             rnorm(100, mean = 4, sd = 3)),
                  groups = factor(rep(c("aaa","bbb","ccc"), each = 100)))

There are several ways. One is to use ?plotmath functionality and the plotmath "function" bold() in an expression:

boxplot(values ~ groups, data = dat,
        ylab = expression(bold(Value~axis)),
        xlab = expression(bold(Single~sample)))

or, similarly

boxplot(values ~ groups, data = dat,
        ylab = expression(bold("Value axis")),
        xlab = expression(bold("Single sample")))

Another way is to leave the titles off the plot and then add them with the title() function using the bold font:

boxplot(values ~ groups, data = dat)
title(ylab = "Value axis", xlab = "Single sample", font.lab = 2)

We need graphical parameter font.lab as this is the parameter that controls the axis labels. Read the entries in ?par for more info.

Upvotes: 9

Related Questions