[R] graphics

jim holtman jholtman at gmail.com
Thu Oct 8 00:23:24 CEST 2009


Here is another way of creating the legend using layout

layout(cbind(1,2), width=c(7,1))
plot(1:10,1:10)
# now create legend
old.par <- par(mar=c(3, 0, 3, 0))
plot.new()
legend('left', legend=c('line 1', 'line 2'))
par(old.par)



On Wed, Oct 7, 2009 at 2:01 PM, McDonald, Grant
<grant.mcdonald08 at imperial.ac.uk> wrote:
>
>
>
> Dear Sir,
>
> I am using the following cos which creates a 3 panel figure on one image.  However the legend function i am using only allows the legend to be placed within the axes of one of the graphs.
>
> The plots however do not allow for a logend to be places within the axes do to the location of points on the graph.  I can add the legend later using imaging software such as paint but i lose resolution by doing this.
>
> Is it possible to place the legend out side of figure axes on the white area around all three panels?
> Any help would be greatly appreciated.
>
> Thank you
> Grant
>
>
>
> single<-read.table("C:\\Grant\\hatchfirstonly.txt",header=T)
> attach(single)
> names(single)
> par(mfrow=c(1,3))
> maleage<- factor(maleage, labels = c("Old","Young"))
> colors <- c('gray', "navyblue")
> shapes <- c(17,19)
> proportion<-(eggs1-unhatch1)/eggs1
> plot(proportion~maleage, xlab= "Age of Male ", ylab = "Proportion of Eggs Hatched")
> plot(proportion~femweight, pch=shapes[maleage], col=colors[maleage],bg="gray", xlab= "Female Weight (grams) ", ylab = " Proportion of Eggs Hatched")
> abline(lm(proportion~femweight))
> plot(proportion~copdurationsecs, pch=shapes[maleage], col=colors[maleage],bg="gray", xlab= "Copulation Duration (minutes) ", ylab = " Proportion of Eggs Hatched")
> abline(lm(proportion~copdurationsecs))
> legend(locator(1), as.character(levels(factor(maleage))),pch=shapes[maleage], col=colors[maleage])(levels(factor(maleage)))
>
> ______________________________________________
> R-help at r-project.org 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list