[CHNOSZ-commits] r569 - in pkg/CHNOSZ: . R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jul 21 03:42:24 CEST 2020


Author: jedick
Date: 2020-07-21 03:42:22 +0200 (Tue, 21 Jul 2020)
New Revision: 569

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/diagram.R
   pkg/CHNOSZ/inst/NEWS.Rd
   pkg/CHNOSZ/man/diagram.Rd
Log:
Add 'min.area' argument to diagram()


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2020-07-19 14:57:12 UTC (rev 568)
+++ pkg/CHNOSZ/DESCRIPTION	2020-07-21 01:42:22 UTC (rev 569)
@@ -1,6 +1,6 @@
-Date: 2020-07-19
+Date: 2020-07-21
 Package: CHNOSZ
-Version: 1.3.6-42
+Version: 1.3.6-43
 Title: Thermodynamic Calculations and Diagrams for Geochemistry
 Authors at R: c(
     person("Jeffrey", "Dick", , "j3ffdick at gmail.com", role = c("aut", "cre"),

Modified: pkg/CHNOSZ/R/diagram.R
===================================================================
--- pkg/CHNOSZ/R/diagram.R	2020-07-19 14:57:12 UTC (rev 568)
+++ pkg/CHNOSZ/R/diagram.R	2020-07-21 01:42:22 UTC (rev 569)
@@ -32,6 +32,7 @@
   # field and line labels
   names=NULL, format.names=TRUE, bold=FALSE, italic=FALSE,
   font=par("font"), family=par("family"), adj=0.5, dy=0, srt=0,
+  min.area=0,
   # title and legend
   main=NULL, legend.x=NA,
   # plotting controls
@@ -561,11 +562,12 @@
         lapply(linesout, `length<-`, max(sapply(linesout, length)))
       }
       ## label plot function
-      plot.names <- function(out, xs, ys, xlim, ylim, names, srt) {
+      plot.names <- function(out, xs, ys, xlim, ylim, names, srt, min.area) {
         # calculate coordinates for field labels
         # revisions: 20091116 for speed, 20190223 work with user-specified xlim and ylim
         namesx <- namesy <- rep(NA, length(names))
         # even if 'names' is NULL, we run the loop in order to generate namesx and namesy for the output 20190225
+        area.plot <- length(xs) * length(ys)
         for(i in seq_along(groups)) {
           this <- which(out==i, arr.ind=TRUE)
           if(length(this)==0) next
@@ -577,6 +579,10 @@
           xsth <- xsth[xsth >= rx[1] & xsth <= rx[2]]
           ysth <- ysth[ysth >= ry[1] & ysth <= ry[2]]
           if(length(xsth)==0 | length(ysth)==0) next
+          # skip plotting names if the fields are too small 20200720
+          area <- max(length(xsth), length(ysth))
+          frac.area <- area / area.plot
+          if(!frac.area >= min.area) next
           namesx[i] <- mean(xsth)
           namesy[i] <- mean(ysth)
         }
@@ -680,7 +686,7 @@
         # put predominance matrix in the right order for image() etc
         zs <- t(predominant[, ncol(predominant):1])
         if(!is.null(fill)) fill.color(xs, ys, zs, fill, ngroups)
-        pn <- plot.names(zs, xs, ys, xlim, ylim, names, srt)
+        pn <- plot.names(zs, xs, ys, xlim, ylim, names, srt, min.area)
         # only draw the lines if there is more than one field  20180923
         # (to avoid warnings from contour, which seem to be associated with weird
         # font metric state and subsequent errors adding e.g. subscripted text to plot)

Modified: pkg/CHNOSZ/inst/NEWS.Rd
===================================================================
--- pkg/CHNOSZ/inst/NEWS.Rd	2020-07-19 14:57:12 UTC (rev 568)
+++ pkg/CHNOSZ/inst/NEWS.Rd	2020-07-21 01:42:22 UTC (rev 569)
@@ -6,7 +6,7 @@
 \newcommand{\H2O}{\ifelse{latex}{\eqn{\mathrm{H_{2}O}}}{\ifelse{html}{\out{H<sub>2</sub>O}}{H2O}}}
 \newcommand{\Hplus}{\ifelse{latex}{\eqn{\mathrm{H^{+}}}}{\ifelse{html}{\out{H<sup>+</sup>}}{H+}}}
 
-\section{Changes in CHNOSZ version 1.3.6-42 (2020-07-19)}{
+\section{Changes in CHNOSZ version 1.3.6-43 (2020-07-21)}{
 
   \subsection{MAJOR CHANGES}{
     \itemize{
@@ -155,6 +155,10 @@
       \strong{bold}, \strong{italic}) now can have length > 1 to apply
       different settings to each species.
 
+      \item Add a \strong{min.area} argument to \code{diagram()} to specify the
+      minimum area of fields that should be labeled. This is useful for
+      removing labels from small fields on very crowded diagrams.
+
     }
   }
 
@@ -207,6 +211,12 @@
 
       \item TODO: get water limits on logfO2-logfS2 diagram (multi-metal.Rmd)
 
+      \item TODO: anintro.Rmd, help files: make it clear that species with
+      different units (cal, J) in OBIGT can be used in subcrt, diagrams, etc.
+      in CHNOSZ.
+
+      \item TODO: for balance = 1, add or change message text to "formula units".
+
     }
   }
 

Modified: pkg/CHNOSZ/man/diagram.Rd
===================================================================
--- pkg/CHNOSZ/man/diagram.Rd	2020-07-19 14:57:12 UTC (rev 568)
+++ pkg/CHNOSZ/man/diagram.Rd	2020-07-21 01:42:22 UTC (rev 569)
@@ -29,6 +29,7 @@
     # field and line labels
     names = NULL, format.names = TRUE, bold = FALSE, italic = FALSE, 
     font = par("font"), family = par("family"), adj = 0.5, dy = 0, srt = 0,
+    min.area = 0,
     # title and legend
     main = NULL, legend.x = NA,
     # plotting controls
@@ -78,6 +79,7 @@
   \item{adj}{numeric, adjustment for line labels}
   \item{dy}{numeric, y offset for line labels}
   \item{srt}{numeric, rotation for line labels}
+  \item{min.area}{numeric, minimum area of fields that should be labeled, expressed as a fraction of the total plot area}
   \item{main}{character, a main \code{\link{title}} for the plot; \code{NULL} means to plot no title}
   \item{legend.x}{character, description of legend placement passed to \code{\link{legend}}}
   \item{add}{logical, add to current plot?}



More information about the CHNOSZ-commits mailing list