[Phylobase-commits] r285 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Aug 26 15:13:35 CEST 2008


Author: jombart
Date: 2008-08-26 15:13:35 +0200 (Tue, 26 Aug 2008)
New Revision: 285

Modified:
   pkg/R/plot.R
Log:
Fixed the scaling of variables : now a common scale is used to plot all symbols.


Modified: pkg/R/plot.R
===================================================================
--- pkg/R/plot.R	2008-08-20 05:02:58 UTC (rev 284)
+++ pkg/R/plot.R	2008-08-26 13:13:35 UTC (rev 285)
@@ -119,8 +119,8 @@
     
     ## merge data and their coordinates
     alldat <- cbind.data.frame(xy.data, unlist(dat)) 
-    fac <- factor(rep(1:ncol(dat), rep(nrow(dat),ncol(dat))))
-    alldat <- split(alldat, fac)
+    ##    fac <- factor(rep(1:ncol(dat), rep(nrow(dat),ncol(dat))))
+    ##     alldat <- split(alldat, fac)
     
     ## need to "reboot" the plot region without changing coordinates
     ## seems that box does the job.
@@ -177,8 +177,11 @@
 
 
     ## finally plot the data
-    lapply(alldat, function(X) plotaux(X[,1],X[,2],X[,3],symbol,cex.symbol))
-
+    ## carefull : all variables must be plotted in as a single vector, so that
+    ## scaling is the same for all variables
+    ## lapply(alldat, function(X) plotaux(X[,1],X[,2],X[,3],symbol,cex.symbol)) 
+    plotaux(alldat[,1],alldat[,2],alldat[,3],symbol,cex.symbol)
+    
     #### plot labels for variables
     if(show.var.label) text(x=x.grid, y=rep(min(y.grid)-1.5*y.inset, ncol(dat)), lab=var.label,
                             adj=1, srt=90, cex=cex.label)
@@ -252,7 +255,7 @@
             y.leg <- y.base ## remember to use y.base instead of par("usr3")[3], which is wrong
         }
 
-        addLegend(x=x.leg, y=y.leg, z=alldat[[1]][,3],
+        addLegend(x=x.leg, y=y.leg, z=alldat[,3],
                   cex.legend=cex.legend, cex.label=cex.label, cex.symbol=cex.symbol)
         ## FIXME ##
         ## draw a rectangle around the legend



More information about the Phylobase-commits mailing list