[R] symbols and legend: how to harmonize point size ?

Patrick Giraudoux patrick.giraudoux at univ-fcomte.fr
Fri Nov 11 20:06:31 CET 2011


Hi,

I was wondering if it is possible to harmonize the ouput of symbols() 
and legend() both from the graphics package.

Let us take this example:

x<-runif(10)
y<-runif(10)
z<-runif(10)

leg<-round(seq(min(z),max(z),l=4),2) # 4 values rounded up to 2 decimals 
for the legend

symbols(x,y,circles=z,inches=0.2)

legend("topright",legend=leg,pch=1,pt.cex=leg/max(leg)*2) # multiplied 
by 2 arbitrarily just to make it visible

Actually, what I want to do is to pass to pt.cex a value which would 
make the biggest circle in the legend (leg/max(leg) = 1) exactly the 
same size as the one specified in symbols (here 0.2 inches). I suppose 
this is possible using par("cin") but I cannot figure out how to do it 
properly.

Any hint appreciated,

Best,

Patrick



More information about the R-help mailing list