[R] Legend titles in log plots broken? (ver. 2.2.1)

Duncan Murdoch murdoch at stats.uwo.ca
Thu May 11 04:40:30 CEST 2006


Rob Steele wrote:
> Legend titles work in linear plots:
> 
> curve(1/x, xlim = c(0, 1))
> legend(x = 'topright', inset = 0.04,
>         legend = '1/x', lty = 1,
>         title = 'Legend Title')
> 
> But when you change to a log plot on either dimension things get screwy:
> 
> curve(1/x, xlim = c(0, 1), log = 'y')
> legend(x = 'topright', inset = 0.04,
>         legend = '1/x', lty = 1,
>         title = 'Legend Title')
> 
> If you save the value legend() returns you can look at it and see that 
> it's messed up:
> 
> l <- legend(x = 'topright', inset = 0.04,
>              legend = '1/x', lty = 1,
>              title = 'Legend Title')

I don't think this is the problem.  It's simply a little bug in legend() 
that puts the title in the wrong place when a log scale is used.  I'll 
fix it.

Duncan Murdoch


> 
>  > l
> $rect
> $rect$w
> [1] 0.2349272
> 
> $rect$h
> [1] 0.2727899
> 
> $rect$left
> [1] 0.7618728
> 
> $rect$top
> [1] 1.9936
> 
> 
> $text
> $text$x
> [1] 0.9188374
> 
> $text$y
> [1] 1.81174
> 
> 
>  > R.Version()
> $platform
> [1] "i686-redhat-linux-gnu"
> 
> $arch
> [1] "i686"
> 
> $os
> [1] "linux-gnu"
> 
> $system
> [1] "i686, linux-gnu"
> 
> $status
> [1] ""
> 
> $major
> [1] "2"
> 
> $minor
> [1] "2.1"
> 
> $year
> [1] "2005"
> 
> $month
> [1] "12"
> 
> $day
> [1] "20"
> 
> $"svn rev"
> [1] "36812"
> 
> $language
> [1] "R"
> 
> ______________________________________________
> 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




More information about the R-help mailing list