vuzun
vuzun

Reputation: 952

Adding subplot labels in R

I'm creating a plot made up of smaller subplots using mfrow in par(), similarly to examples here.

Is there a way to add labels (A, B, C, ...) programmatically in the top corner of each of the subplots? Something like the letters in this plot.

Upvotes: 2

Views: 1069

Answers (1)

G5W
G5W

Reputation: 37641

Yes. You can add text to the margin using the mtext function.

par(mfrow=c(2,2))
for(i in 2:5) {
    plot(mtcars[,c(1,i)], pch=20)
    mtext(LETTERS[i-1], adj=0, line=1)
}

Plots with marginal text

Upvotes: 4

Related Questions