Bug 15285 - In plot.lm() with which=5, the legend "Cook's distance" can overwrite a point label
Summary: In plot.lm() with which=5, the legend "Cook's distance" can overwrite a point...
Status: NEW
Alias: None
Product: R
Classification: Unclassified
Component: Graphics (show other bugs)
Version: R 3.0.0
Hardware: x86_64/x64/amd64 (64-bit) Mac OS X v10.8
: P5 minor
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2013-04-20 05:25 UTC by John H Maindonald
Modified: 2013-04-20 05:25 UTC (History)
0 users

See Also:


Attachments
plot(mf.lm, which=5) as above; then call dev.copy(); etc. (7.02 KB, application/pdf)
2013-04-20 05:25 UTC, John H Maindonald
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John H Maindonald 2013-04-20 05:25:10 UTC
Created attachment 1428 [details]
plot(mf.lm, which=5) as above; then call dev.copy(); etc.

Try for example:

library(DAAG)
mf.lm <- lm(log(timef)~log(time), data=nihills)
quartz(width=4, height=4)
plot(mf.lm, which=5)

I propose the following (line numbers are those shown when I use edit() to edit the function,
running under the Mac GUI):
line 190: Replace
            ylim <- extendrange(r = ylim, f = 0.08)
with
            ylim <- ylim + c(-0.12, 0.08)*diff(ylim)


lines 258-259: Replace
                legend("bottomleft", legend = "Cook's distance", 
                  lty = 2, col = 2, bty = "n")
with
               legend("bottomleft", legend = "Cook's distance", 
                  lty = 2, col = 2, bty = "n", y.intersp=0.25, text.col=2)

If y.intersp is left at its default y.intersp=1, then in  ylim <- ylim + c(-0.12, 0.08)*diff(ylim),
the -0.12 needs to be reduced further. 

Wishlist: I am suggesting text.col=2 in order to clearly distinguish the legend "Cook's distance" from labels on points, and because the Cook's distance contours are shown in red.