From f78a6461cb0510d606fa420bd8fc1683a8815d4b Mon Sep 17 00:00:00 2001 From: ranke Date: Fri, 15 Jul 2005 11:28:06 +0000 Subject: Some cleanup of the legend positioning, which can be used starting from R version 2.1.0. git-svn-id: http://kriemhild.uft.uni-bremen.de/svn/drfit@28 d1b72e20-2ee0-0310-a1c4-ad5adbbefcdc --- R/drfit.R | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'R') diff --git a/R/drfit.R b/R/drfit.R index db7bf50..38f8e75 100644 --- a/R/drfit.R +++ b/R/drfit.R @@ -235,7 +235,7 @@ drfit <- function(data, startlogEC50 = NA, chooseone=TRUE, drplot <- function(drresults, data, dtype = "std", alpha = 0.95, path = "./", fileprefix = "drplot", overlay = FALSE, postscript = FALSE, png = FALSE, bw = TRUE, - colors = 1:8,devoff=T,lpos=FALSE) + colors = 1:8,devoff=T,lpos="topright") { unitlevels <- levels(as.factor(drresults$unit)) if (length(unitlevels) == 1) { @@ -264,15 +264,6 @@ drplot <- function(drresults, data, dtype = "std", alpha = 0.95, } } - # Legend position - if (!lpos[[1]]) { - lx <- lhd - 1 - ly <- hr + 0.1 - } else { - lx <- lpos[[1]] - ly <- lpos[[2]] - } - # Prepare overlay plot if requested if (overlay) { @@ -335,7 +326,7 @@ drplot <- function(drresults, data, dtype = "std", alpha = 0.95, xlab=paste("Decadic Logarithm of the dose in ", unit), ylab="Normalized response") } - if (!overlay) legend("topright", i,lty = 1, col = color, inset=0.05) + if (!overlay) legend(lpos, i,lty = 1, col = color, inset=0.05) tmp$dosefactor <- factor(tmp$dose) # necessary because the old # factor has all levels, not # only the ones tested with @@ -402,7 +393,7 @@ drplot <- function(drresults, data, dtype = "std", alpha = 0.95, } } } - if (overlay) legend("topright", dsubstances,lty = 1, col = colors, inset=0.05) + if (overlay) legend(lpos, dsubstances,lty = 1, col = colors, inset=0.05) if (overlay && (postscript || png)) { if (devoff) { dev.off() @@ -484,7 +475,7 @@ checkplate <- function(plate,db="cytotox") points(log10(drdatalist[[i]]$conc),drdatalist[[i]][[responsetype]],col=i); } - legend(3.0,1.5,substances, pch=1, col=1:length(substances)) + legend("topright",substances, pch=1, col=1:length(substances), inset=0.05) title(main=paste("Plate ",plate," - ",levels(platedata$experimentator)," - ",levels(platedata$type))) } } @@ -540,7 +531,7 @@ checksubstance <- function(substance,db="cytotox",experimentator="%",celltype="% points(log10(platelist[[i]]$conc),platelist[[i]][[responsetype]],col=i); } - legend(3.5,1.7,plates, pch=1, col=1:length(plates)) + legend("topright", plates, pch=1, col=1:length(plates), inset=0.05) title(main=paste(substance," - ",levels(data$experimentator)," - ",levels(data$type))) cat("Substanz ",substance,"\n", -- cgit v1.2.1