[R] Troubles in plotting to a postscript file (not to png)

David Winsemius dwinsemius at comcast.net
Mon Nov 29 15:46:08 CET 2010


On Nov 29, 2010, at 9:00 AM, pilchat wrote:

> Hi guys,
>
> to make it easier, here is a simple case with the same issues. I use  
> the short function below to make the attached PS file.
>
> Things to fix:
>
> -) the greek letter "lambda" is not printed, while "mu" is printed  
> (see the plot command)
> -) the annotation inside the plot area: the "+-" symbol and "(K)"  
> overlap with the substitute for tmed and tstd respectively (see the  
> text command). Also, how can I set the number of decimal digits for  
> tmed and tstd? (option(digits=4) does not work )

I would have thought one would do any formatting (of digits) outside  
the text( ...substitute(...),...) setting.

>
> Moreover, I'd like to make the characters thicker. Is there any way?

Which characters? There is a bold() option within plotmath.

> Finally, once I close the R session without saving it (I answer "n"  
> when quitting), the content of the ps file is erased.

Now _that_ is weird. A file should have been created in your default  
directory and closing R should not have made it go away.

> Do I miss something in writing the function?

Perhaps. (But you certainly missed something in writing the question.)  
When I remove the family="ComputerModern" from the postscript call, I  
start seeing lambda. ,,,, And the other spacing weirness also  
resolves. I am on a Mac and ComputerModern is not one of the  
pdfFonts() on my machine. The list of available fonts varies widely  
across various OSes and devices about which you have given us no clues.

-- 
David.

>
> Thanks
>
> Gaetano
>
>
> plot_example=function()
> {
>
> setPS()
> postscript (file='plot_example.ps',width=5,height=5,horizontal =  
> FALSE, paper = "special",family =  
> "ComputerModern",encoding="TeXtext.enc")
>
> tmed<-1.23456789
> tstd<-1.23456789
>
> plot 
> (c 
> (0,1 
> ),c 
> (0,1 
> ),xlab=expression(paste(lambda,mu,T)),main="",sub="(a)")#"lambda"  
> not printed
> text(.0,.8,substitute( T[disk,med] == tmed %+-% tstd  
> (K),list(tmed=tmed,tstd=tstd)),pos=4,cex=1.5  )#overlapping symbols  
> and numbers
>
> dev.off()
>
> }
> <plot_example.ps>______________________________________________
> R-help at r-project.org 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list