[R] distance between legend title and legend box

2006-10-26 Thread Denis Chabot
Hi,

I've looked at the parameters available for the legend function and  
cannot find a way to change the distance between the top of the box  
surrounding a legend and the legend's title. I have a math expression  
that raises the height of my title.

If you don't mind the non-sensical title I give to the legend for  
this plot (Figure 3.20 in R Graphics):

with(iris,
   plot(Sepal.Length, Sepal.Width,
pch=as.numeric(Species), cex=1.2))
legend(6.5, 4.2, c(setosa, versicolor, virginica),
   cex=1, pch=1:3, title=expression(kg/km^2))

The result depends on the device, but I think any device will show  
the box needs to be raised a bit (in quartz, the top of the box  
passes in the middle of the 2, in pdf it is acceptable, but just  
(the top of the box lightly touches the top of the 2).

Sincerely,

Denis Chabot

__
R-help@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.


Re: [R] distance between legend title and legend box

2006-10-26 Thread David Barron
I don't know if there is a nice, easy way of doing this, but this
method will work:

with(iris,
  plot(Sepal.Length, Sepal.Width,
   pch=as.numeric(Species), cex=1.2))

lg-legend(6.5, 4.2, c(setosa, versicolor, virginica),
  cex=1, pch=1:3, title=expression(kg/km^2), bty=n)

x1 - lg$rect$left
y1 - lg$rect$top - lg$rect$h
x2 - x1 + lg$rect$w
y2 - lg$rect$top + .1  # change the .1 to get more or less space

rect(x1,y1,x2,y2)


On 26/10/06, Denis Chabot [EMAIL PROTECTED] wrote:
 Hi,

 I've looked at the parameters available for the legend function and
 cannot find a way to change the distance between the top of the box
 surrounding a legend and the legend's title. I have a math expression
 that raises the height of my title.

 If you don't mind the non-sensical title I give to the legend for
 this plot (Figure 3.20 in R Graphics):

 with(iris,
plot(Sepal.Length, Sepal.Width,
 pch=as.numeric(Species), cex=1.2))
 legend(6.5, 4.2, c(setosa, versicolor, virginica),
cex=1, pch=1:3, title=expression(kg/km^2))

 The result depends on the device, but I think any device will show
 the box needs to be raised a bit (in quartz, the top of the box
 passes in the middle of the 2, in pdf it is acceptable, but just
 (the top of the box lightly touches the top of the 2).

 Sincerely,

 Denis Chabot

 __
 R-help@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.



-- 
=
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP

__
R-help@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.


Re: [R] distance between legend title and legend box

2006-10-26 Thread Paul Murrell
Hi


Denis Chabot wrote:
 Hi,
 
 I've looked at the parameters available for the legend function and  
 cannot find a way to change the distance between the top of the box  
 surrounding a legend and the legend's title. I have a math expression  
 that raises the height of my title.
 
 If you don't mind the non-sensical title I give to the legend for  
 this plot (Figure 3.20 in R Graphics):
 
 with(iris,
plot(Sepal.Length, Sepal.Width,
 pch=as.numeric(Species), cex=1.2))
 legend(6.5, 4.2, c(setosa, versicolor, virginica),
cex=1, pch=1:3, title=expression(kg/km^2))
 
 The result depends on the device, but I think any device will show  
 the box needs to be raised a bit (in quartz, the top of the box  
 passes in the middle of the 2, in pdf it is acceptable, but just  
 (the top of the box lightly touches the top of the 2).


Looking at the source for legend(), it only expects the title to be zero
or 1 lines high (i.e., either no title or a title that is one line of
normal text high).  It needs a rewrite to allow for the exact height of
the title text.

Paul


 Sincerely,
 
 Denis Chabot
 
 __
 R-help@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
[EMAIL PROTECTED]
http://www.stat.auckland.ac.nz/~paul/

__
R-help@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.