Multi-line y label in plot

Is there a way to create multi-line labels for the y axis on the R plot?

I tried to add \nwhere the new line should be, but then the first line of the label is truncated:

l <- 10
plot(0:l, (0:l), type='l',
     yaxt='n',
     xlab='Index',
     ylab='Cumulative sum\nof the sorted weights')

Result of plot

This happens both with tikzDeviceand inside RStudio. In addition, I tried some of the options par()with no luck. How to do it right?

(Lack of margin bothers me too ...)

+3
source share
2 answers

You need to set the fields with maror mgp:

l <- 10
op <- par(mar=c(5, 6, 4, 2) + 0.1)
plot(0:l, (0:l), type='l',
     yaxt='n',
     xlab='Index',
     ylab='Cumulative sum\nof the sorted weights')
par(op)

enter image description here

+9
source

Like @smillig, you do this with par, by changing the parameters maror mgp.

par , plot.

+1

All Articles