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 --- DESCRIPTION | 2 +- R/drfit.R | 19 +++++-------------- man/drplot.Rd | 4 +++- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c9de7dc..3eee40b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: drfit -Version: 0.03-27 +Version: 0.03-28 Date: 2005-07-16 Title: Dose-response data evaluation Author: Johannes Ranke 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", diff --git a/man/drplot.Rd b/man/drplot.Rd index b162d45..ecd6895 100644 --- a/man/drplot.Rd +++ b/man/drplot.Rd @@ -63,7 +63,9 @@ This is a vector of colors, defaulting to 1:8, used for plotting the data. } \item{lpos}{ - A optional vector with the x and y position of the upper left corner of the legend. The default guess is not always the optimum.} + An optional argument defaulting to "topright" specifying the position + of the legend by being passed to the legend function. See the help for the + legend function for all possiblities.} \item{devoff}{ If set to FALSE, the closing of the device after creation of an overlay png or postscript graph will be left out, so texts and other elements can be -- cgit v1.2.1