[R] \n and italic() in legend()

Marc Girondot marc_grt at yahoo.fr
Thu Dec 29 10:35:15 CET 2016


Hi everyone,

Could someone help me to get both \n (return) and italic() in a legend. 
Here is a little example showing what I would like (but without the 
italic) and second what I get:

plot(1, 1)
v1 <- "p-value\nbased on t-test"
legend("topright", legend=v1, y.intersp = 3, bty="n")

plot(1, 1)
v1 <- expression(italic("p")*"-value\nbased on "*italic("t")*"-test")
legend("topright", legend=v1, y.intersp = 3, bty="n")

The second one shows :

-value
pbased on t-test

rather than the expected:

p-value
based on t-test

Thanks a lot,

Marc



More information about the R-help mailing list