[R] setting font in plots
Paul Murrell
p.murrell at auckland.ac.nz
Thu Mar 1 19:46:01 CET 2007
Hi
Mark Allen wrote:
> Dear Reader
>
> I am trying to change the font in a plot and after several trials finally
> came up with the following code.
>
> plot(var_a, var_b, pch = 16, font.lab = 10, font = 10)
> points(var_a, var_c, pch = 3, font = 10)
> legend(0.1, 0.8, legend = c(“var_b”, “var_c”), pch = c(16,3))
>
> It does change the font in the plot (Courier), but not in the legend that
> does not accept the "font = ..." argument. I could also not find a list with
> font names and corresponding numbers.
>
> Surely there must be a better way to do this that I cannot seem to find.
> Looking at the R website I came across e.g. gpar() and par(), but
> unfortunately could not make it work... Is there perhaps anyone that could
> help me out here?
Try ...
par(family="mono")
var_a <- 1:10
var_b <- 1:10
var_c <- 10:1
plot(var_a, var_b, pch = 16)
points(var_a, var_c, pch = 3)
legend(1, 6, legend = c("var_b", "var_c"), pch = c(16,3))
... and take a look at "Fonts, Lines, and Transparency in R Graphics" in
http://cran.stat.auckland.ac.nz/doc/Rnews/Rnews_2004-2.pdf
Paul
> Thanks very much
> Mark Allen
>
> _________________________________________________________________
> Advertisement: It's simple! Sell your car for just $20 at carsales.com.au
>
>
>
> ------------------------------------------------------------------------
>
> ______________________________________________
> 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.
--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/
More information about the R-help
mailing list