[R] Plot math symbol with string and number

Paul Murrell p@u| @end|ng |rom @t@t@@uck|@nd@@c@nz
Tue Aug 18 01:02:37 CEST 2020


I think that comment is fair *on graphics devices that can handle unicode*.

So that is true for Cairo-based graphics devices, but not for the pdf() 
or postscript() devices, for example.

Paul

On 18/08/20 9:54 am, Bert Gunter wrote:
> "Plotmath seems to be the right way to do it."
> 
> Not sure I agree with that. Paul Murrell put together plotmath around 2000
> prior to the widescale development and adoption of the unicode standard
> (corrections/modifications welcome!).  So at the time, there really was no
> other way to handle this for most OS'es. With UTF8 now being generally
> supported for Unicode, plotmath constructions may not be needed for simple
> symbol labeling, as here. Of course for more complex symbolism (fractions,
> integrals, ...) it will be. ?plotmath talks about this and has links to
> further issues and options, btw.
> 
> In other words, unicode may indeed be better than my suggestion of plotmath
> here.
> 
> I would welcome comments from others who are more knowledgeable about this
> than I am.
> 
> Bert
> 
> On Mon, Aug 17, 2020 at 2:14 PM <cpolwart using chemo.org.uk> wrote:
> 
>> 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))
>>
>>
>>
>>
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-help&data=02%7C01%7C%7C3624d54caaf64787734308d842f83677%7Cd1b36e950d5042e9958fb63fa906beaa%7C0%7C0%7C637332981200092221&sdata=U7ywrEh7Z3XV84pkxXfzUJTYU8BEZ995Np5xo3%2Fbn9g%3D&reserved=0
> PLEASE do read the posting guide https://apc01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.html&data=02%7C01%7C%7C3624d54caaf64787734308d842f83677%7Cd1b36e950d5042e9958fb63fa906beaa%7C0%7C0%7C637332981200092221&sdata=7VBd7dQFox%2BCEUEKgJZk6TU6cwmDS7tnAcGok9UH1WQ%3D&reserved=0
> and provide commented, minimal, self-contained, reproducible code.
> 

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul using stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/



More information about the R-help mailing list