[R] legends and fonts

Alistair Merrifield Alistair.Merrifield at med.govt.nz
Thu Jan 25 23:47:03 CET 2001


Dear all,

1)	I am a recent convert from S+ to R. I was fiddling around with
legends on a plot when I noticed that the S+ command "key" is absent in R.
What I want to do is having used a point for one variable in a plot and used
a line for another, put a legend in the plot so that the point is by the 1st
variable name and the line is next to the second variable name. I used to
use the "key" command in S as it had the arguement "lines" which allowed me
do to exactly that. In the (S+) example below, I have explicitly specified
that points are to be used for both variables in the legend:

key(160, -35, lines = list(type = c("p", "p")), text = list(c("Earthquakes",
"Foreshocks")), 
				  border = 0, pch = c(18, 16), cex =  0.9,
col = c(7, 5))

I was curious as to whether there was an easy (or similar) way to to this in
R? I have got around the problem for the time being by defining the point
character to use in the plot. An example is provided below:

windows()
plot(Time,exp(Response),ylab="Petrol Demand (PJ)",pch="*")
lines(Time,exp(fitted.values(TotVehc.Mod)),lwd=2,col="red")
xcoord<-par()$usr[1]
ycoord<-par()$usr[4]
legend(xcoord,ycoord,c("Petrol Consumption","Fitted Petrol Consumption"),
		lty=c(0,1),pch=c("*"," "),col=c(1,"red"),bty="n",lwd=2)

2)	Whilst I am at it, I wonder if anyone has created any additional
fonts for graphics in R? I have been using the "postscript" command to
produce graphs. The range of fonts are fine by me, but the "powers that be"
expressed an interest in using Verdana font (a Windows true type font). I
have used the Helvetica font which is close enough for me (and them), but I
was curious as to any other fonts (in particular Verdana) that are
available.

Cheers, Al.

(I am using R 1.2.1, regrettably the Windows version).

Al Merrifield

Energy Analyst
Energy Modelling & Statistics
Ministry of Economic Development
PO Box 1473
Wellington
NEW ZEALAND

Phone: (04) 470 2338
Fax:     (04) 473 9930
E-mail: Alistair.Merrifield at med.govt.nz



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list