[R] persp and greek symbols in the axes labels

Nathalie Peyrard Nathalie.Peyrard at toulouse.inra.fr
Tue Jul 24 14:57:27 CEST 2007


Thank you for these answers.

I ended up modifying the ps file directly. But next time I will consider 
wireframe.

Nathalie

Prof Brian Ripley wrote:
> On Tue, 24 Jul 2007, Stephen Tucker wrote:
>
>> I don't know why it doesn't work but I think people generally 
>> recommend that
>
> It has never been implemented, and I believe the main reason is that 
> the labels are plotted at an angle other than a multiple of 90 
> degrees.  Not all devices can do that, and rotated plotmath text can 
> look quite ugly.
>
> And of course this _is_ documented in ?persp
>
> xlab, ylab, zlab: titles for the axes.  N.B. These must be character
>           strings; expressions are not accepted.  Numbers will be
>           coerced to character strings.
>
>> you use wireframe() in lattice rather than persp(), because wireframe 
>> is more
>> customizable (the pdf document referred to in this post is pretty good):
>> http://tolstoy.newcastle.edu.au/R/e2/help/07/03/12534.html
>>
>> Here's an example:
>>
>> library(lattice)
>> library(reshape)
>> x <- 1:5
>> y <- 1:3
>> z <- matrix(1:15,ncol=3,dimnames=list(NULL,y))
>> M <- melt(data.frame(x,z,check.names=FALSE),id=1,variable="y")
>> wireframe(value~x*y,data=M,
>>          screen=list(z=45,x=-75),
>>          xlab=expression(kappa[lambda]),
>>          ylab=as.expression(substitute(paste(phi,"=",true,sigma),
>>              list(true=5))),
>>          zlab = "Z")
>>
>> [you can play around with the 'screen' argument to rotate the view, 
>> analogous
>> to phi and theta in persp()]
>
> Of course, that does not rotate the labels.   If unrotated labels are 
> acceptable, you can easily set up a new coordinate system (by 
> par(usr=)) and call text() to put labels where you want on that.  You 
> can even try rotating them via srt=.
>
> There would be no harm in implementing this for use on devices where 
> it will work: a nice self-contained project for someone who would like 
> to learn about R internals.
>
>
>> --- Nathalie Peyrard <Nathalie.Peyrard at toulouse.inra.fr> wrote:
>>
>>> Hello,
>>>
>>> I am plotting a 3D function using persp and I would like to use greek
>>> symbols in the axes labels.
>>> I  have found examples like  this one on the web:
>>>
>>>
>> plot(0,0,xlab=expression(kappa[lambda]),ylab=substitute(paste(phi,"=",true,sigma),list(true=5))) 
>>
>>>
>>> this works well with plot but not with persp:
>>> with the command
>>>
>>> persp(M,theta = -20,phi =
>>>
>> 0,xlab=expression(kappa[lambda]),ylab=substitute(paste(phi,"=",true,sigma),list(true=5)),zlab 
>>
>>>
>>> = "Z")
>>>
>>> I get the labels as in toto.eps
>>>
>>> Any suggestion? Thanks!
>>>
>>> Nathalie
>>>
>>> -- 
>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>> INRA  Toulouse - Unité de Biométrie et  Intelligence Artificielle
>>> Chemin de Borde-Rouge BP 52627 31326 CASTANET-TOLOSAN cedex FRANCE
>>> Tel : +33(0)5.61.28.54.39 - Fax : +33(0)5.61.28.53.35
>>> Web :http://mia.toulouse.inra.fr/index.php?id=217
>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>
>>>
>>>> ______________________________________________
>>> R-help at stat.math.ethz.ch mailing list
>>> 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.
>>>
>>
>>
>>
>>
>> ____________________________________________________________________________________Ready 
>> for the edge of your seat?
>> Check out tonight's top picks on Yahoo! TV.
>>
>> ______________________________________________
>> R-help at stat.math.ethz.ch mailing list
>> 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.
>>
>



More information about the R-help mailing list