Hi,
Thanks a lot to Duncan Mackay for the trick using atop() [but the
legends are centered and not left aligned] and also for the suggestion
of William Michels to use simply ",". However this last solution
prevents to use several legends.
Here is a solution to allow both return within a legend and several legends:
plot(1, 1)
v1 <- c(expression(italic("p")*"-value"), expression("based on
"*italic("t")*"-test"))
v2 <- c(expression(italic("w")*"-value for A"), expression("and B
identical models"))
legend("topright", legend=c(v1, v2), lty=c(1, 0, 1, 0), y.intersp = 1,
bty="n", col=c("black", "", "red", ""))
Thanks again
Marc
Le 29/12/2016 à 10:54, Duncan Mackay a écrit :
Hi Marc
Try atop
plot(1, 1)
v1 <- expression(atop(italic("p")*"-value","based on "*italic("t")*"-test"))
legend("topright", legend=v1, y.intersp = 3, bty="n")
Regards
Duncan
Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mac...@northnet.com.au
-----Original Message-----
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Marc
Girondot via R-help
Sent: Thursday, 29 December 2016 20:35
To: R-help Mailing List
Subject: [R] \n and italic() in legend()
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
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.