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? Thanks very much Mark Allen _________________________________________________________________ Advertisement: It's simple! Sell your car for just $20 at carsales.com.au
On Thu, 2007-03-01 at 23:48 +1000, 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? > > Thanks very much > Mark AllenMark, In ?par, note 'family', which can take on the values: "serif", "sans", "mono", and "symbol", as well as supporting the Hershey fonts. So, if you want a mono font in the legend, use: par(family = "mono") before your legend() call: plot(1:10) par(family = "mono") legend("topleft", legend = "This is a test") HTH, Marc Schwartz
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/
Reasonably Related Threads
- import data (txt) separated by many blank spaces and lines with variable names that correspond to multiple observations.
- Help with "MERGE" gratefully accepted
- [LLVMdev] Cc llvmdev: Re: llvm bpf debug info. Re: [RFC PATCH v4 3/3] bpf: Introduce function for outputing data to perf event
- descriptive statistics
- Assigning constant value without alloca/load/store