I cannot get the "inset" argument in legend() to produce the results that I want. It seems to me that when the legend position argument is set to "bottom" then only the second (y-component) entry of "inset" has any effect, and when the position argument is "left" then only the first (x-component) entry of "inset" has any effect.
I have attached a file "legDemo.txt" which can be sourced to demonstrate the behaviour that I am encountering. I thought that maybe if one uses "inset" then one should not specify the legend position, but that causes an error to be thrown. I want to have a near the bottom of the plot and to adjust its position, in the horizontal direction by means of "inset", but nothing that I try has the desired effect. Am I misunderstanding something? Or is there perhaps a bug in legend()? cheers, Rolf Turner -- Honorary Research Fellow Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276
set.seed(42) kull <- sample(1:4,10,TRUE) leg <- c("A","B","C","D") # 1. plot(1:10,col=kull,pch=20,axes=FALSE,ann=FALSE) box() legend("left",pch=20,col=kull,legend=leg,bty="n") readline("Go? ") # 2. plot(1:10,col=kull,pch=20,axes=FALSE,ann=FALSE) box() legend("left",pch=20,col=kull,legend=leg,bty="n",inset=c(0.75,0.75)) readline("Go? ") # 3. plot(1:10,col=kull,pch=20,axes=FALSE,ann=FALSE) box() legend("bottom",pch=20,col=kull,legend=leg,bty="n",horiz=TRUE) readline("Go? ") # 4. plot(1:10,col=kull,pch=20,axes=FALSE,ann=FALSE) box() legend("bottom",pch=20,col=kull,legend=leg,bty="n",horiz=TRUE,inset=c(0.75,0.75)) readline("Go? ") # 5. plot(1:10,col=kull,pch=20,axes=FALSE,ann=FALSE) box() legend("bottom",pch=20,col=kull,legend=leg,bty="n",horiz=TRUE,inset=c(0.75,0)) readline("Go? ") # 6. plot(1:10,col=kull,pch=20,axes=FALSE,ann=FALSE) box() legend("bottom",pch=20,col=kull,legend=leg,bty="n",horiz=TRUE,inset=c(0,0.75))
______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.