Specifically, see the "how to combine "math" and numeric variables" in the Examples therein. Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Sun, Aug 16, 2020 at 3:18 PM Bert Gunter <bgunter.4567 at gmail.com> wrote:> ?plotmath > > On Sun, Aug 16, 2020, 14:53 John Smith <jswhct at gmail.com> wrote: > >> Dear Helpers, >> >> I would like to make plots with titles for different data sets and >> different parameters. So a useful title should combine data name >> and parameter for clarity. The following is a simplified code example with >> two plots. The first title doesn't show sigma as a math symbol, while the >> second one doesn't contain the s value as a numeric value - I could >> manually change the s value, but when there are many different s values, >> this is not a good solution. Thanks! >> >> s <- 1 >> y <- rnorm(100) >> plot(y, main=paste("data", "sigma=", s)) >> plot(y, main=expression(paste("data", sigma,"=", s))) >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at 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. >> >[[alternative HTML version deleted]]
On Sun, Aug 16, 2020 at 3:18 PM Bert wrote: | On Sun, Aug 16, 2020, 14:53 John wrote: | | | | I would like to make plots with | | titles for different data sets and | | different parameters. The first | | title doesn't show sigma as a math | | symbol, while the second one | | doesn't contain the s value as a | | numeric value | | | | s <- 1 | | y <- rnorm(100) | | plot(y, main=paste("data", "sigma=", s)) | | plot(y, main=expression(paste("data", sigma,"=", s))) | | ?plotmath Dear John, read ?plotmath, it is good, I was not aware of its existence; then backquote s like so: plot(y, main=bquote(paste( "data" ~~ widehat(aleph) %notin% .(s)^.(s)))) V r
Thanks to Dunkan, Rasmus and Bert. Will keep the very useful tips. Best! On Sun, Aug 16, 2020 at 9:13 PM Rasmus Liland <jral at posteo.no> wrote:> On Sun, Aug 16, 2020 at 3:18 PM Bert wrote: > | On Sun, Aug 16, 2020, 14:53 John wrote: > | | > | | I would like to make plots with > | | titles for different data sets and > | | different parameters. The first > | | title doesn't show sigma as a math > | | symbol, while the second one > | | doesn't contain the s value as a > | | numeric value > | | > | | s <- 1 > | | y <- rnorm(100) > | | plot(y, main=paste("data", "sigma=", s)) > | | plot(y, main=expression(paste("data", sigma,"=", s))) > | > | ?plotmath > > Dear John, read ?plotmath, it is good, I > was not aware of its existence; then > backquote s like so: > > plot(y, main=bquote(paste( > "data" ~~ widehat(aleph) > %notin% .(s)^.(s)))) > > V > > r >[[alternative HTML version deleted]]
cpoiw@rt m@iii@g oii chemo@org@uk
2020-Aug-17 21:14 UTC
[R] Plot math symbol with string and number
On 2020-08-17 03:13, Rasmus Liland wrote:> On Sun, Aug 16, 2020 at 3:18 PM Bert wrote: > | On Sun, Aug 16, 2020, 14:53 John wrote: > | | > | | I would like to make plots with > | | titles for different data sets and > | | different parameters. The first > | | title doesn't show sigma as a math > | | symbol, while the second one > | | doesn't contain the s value as a > | | numeric value > | | > | | s <- 1 > | | y <- rnorm(100) > | | plot(y, main=paste("data", "sigma=", s)) > | | plot(y, main=expression(paste("data", sigma,"=", s))) > | > | ?plotmath > > Dear John, read ?plotmath, it is good, I > was not aware of its existence; then > backquote s like so: > >Plotmath seems to be the right way to do it. But without reading plotmath I'd have gone with this: plot(y, main=paste("data", "\u03C3=", s))