[R] How can I change font type in graph (including all the text in lagend, and the number in x-y axis)

David Winsemius dwinsemius at comcast.net
Sat Jan 14 21:06:46 CET 2012


On Jan 14, 2012, at 2:19 PM, Yakamu Yakamu wrote:

> Dear all,
> I would like to make a survival analysis graph line with all fonts  
> in Times New Roman,
> Including all the numbers in x-y axis and the legend explanation.
> I know how to change fonts for the x-y axis labels (from http://www.statmethods.net/advgraphs/parameters.html 
>  )
> and this is what i did :
> # SURVIVAL PLOT
> colsurvival<-c("black", "black", "black", "black")
> windowsFonts(A=windowsFont("Times New Roman"))
>
> plot(fit1, lty=c(2, 1, 4, 3), lwd=2, col=colsurvival, yscale=100,  
> frame.plot=FALSE)
> title(xlab="results", cex.lab=1.3, cex.axis=1.3, ylab="percentage  
> survival", family="A")
> legend(“bottomleft”, ………etc…)
> I have the titles all in TimesNEw Roman, but not the number in x-y  
> axis.

(Since you only passed "A" as an argument to `title`. Why would this  
be expected to "bleed over" into the axis? I doubt that cex.axis is  
having any effect, either.)

> Is there anyone can help me here? Thank you very much in advance,

You may want to see if passing a "family" argument to `plot` has an  
effect on what is eventually a call to `axis`. That's also (probably)   
where you should be inserting the "cex.axis". Cannot test since I  
don't use windows (and you didn't include a reproducible  sample,  
anyway.)
(In other situations the "font" argument is often a number rather than  
the results of a call to a font-function. See the par help page)



> Kind regards,
> Yakamu
>
> 	[[alternative HTML version deleted]]

You should learn to post in plain text and PLEASE stop replying to  
existing thresads when yu are submitting a new question. It screws up  
the threading.

> 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