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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Apr 11 11:00:12 CEST 2019


Author: jedick
Date: 2019-04-11 11:00:12 +0200 (Thu, 11 Apr 2019)
New Revision: 431

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/diagram.R
   pkg/CHNOSZ/inst/NEWS
   pkg/CHNOSZ/man/diagram.Rd
Log:
diagram(): 'fill' can now be the name of an HCL palette (for R >= 3.6.0)


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2019-04-08 00:48:38 UTC (rev 430)
+++ pkg/CHNOSZ/DESCRIPTION	2019-04-11 09:00:12 UTC (rev 431)
@@ -1,6 +1,6 @@
-Date: 2019-04-08
+Date: 2019-04-11
 Package: CHNOSZ
-Version: 1.3.1-11
+Version: 1.3.1-12
 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	2019-04-08 00:48:38 UTC (rev 430)
+++ pkg/CHNOSZ/R/diagram.R	2019-04-11 09:00:12 UTC (rev 431)
@@ -27,7 +27,7 @@
   lty=NULL, lwd=par("lwd"), dotted=NULL, spline.method=NULL, contour.method="edge",
   # colors
   col=par("col"), col.names=par("col"), fill=NULL,
-  fill.NA="slategray1", limit.water=TRUE,
+  fill.NA="gray80", limit.water=TRUE,
   # 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,
@@ -547,14 +547,20 @@
       ### now on to the diagram itself
 
       # colors to fill predominance fields
-      # default to heat colors if we're on screen, or to transparent if we're adding to a plot
-      if(missing(fill)) {
-        if(add) fill <- "transparent"
-        else if(any(grepl(names(dev.cur()), c("X11cairo", "quartz", "windows")))) fill <- "heat"
-      }
-      if(is.null(fill)) fill <- "transparent"
+      if(is.null(fill) | length(fill)==0) fill <- "transparent"
       else if(isTRUE(fill[1]=="rainbow")) fill <- rainbow(ngroups)
       else if(isTRUE(fill[1] %in% c("heat", "terrain", "topo", "cm"))) fill <- get(paste0(fill[1], ".colors"))(ngroups)
+      else if(getRversion() >= "3.6.0") {
+        # choose an HCL palette 20190411
+        # matching adapted from hcl.colors()
+        fx <- function(x) tolower(gsub("[-, _, \\,, (, ), \\ , \\.]", "", x))
+        p <- charmatch(fx(fill), fx(grDevices::hcl.pals()))
+        if(!is.na(p)) {
+          if(!p < 1L) {
+            fill <- grDevices::hcl.colors(ngroups, fill)
+          }
+        }
+      }
       fill <- rep(fill, length.out=ngroups)
       # modify the default for fill.NA
       if(add & missing(fill.NA)) fill.NA <- "transparent"

Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS	2019-04-08 00:48:38 UTC (rev 430)
+++ pkg/CHNOSZ/inst/NEWS	2019-04-11 09:00:12 UTC (rev 431)
@@ -1,4 +1,4 @@
-CHANGES IN CHNOSZ 1.3.1-11 (2019-04-08)
+CHANGES IN CHNOSZ 1.3.1-12 (2019-04-11)
 ---------------------------------------
 
 - Add thermo/stoich.csv.xz (loaded as thermo()$stoich), containing a
@@ -22,6 +22,9 @@
 - obigt.Rmd: Use Zenodo DOI for citations to slop98.dat, slop07.dat, and
   slop16.dat.
 
+- diagram(): Starting with R version 3.6.0, 'fill' can be the name of
+  any available HCL-based color palette (see hcl.pals() for a list).
+
 CHANGES IN CHNOSZ 1.3.1 (2019-03-02)
 ------------------------------------
 

Modified: pkg/CHNOSZ/man/diagram.Rd
===================================================================
--- pkg/CHNOSZ/man/diagram.Rd	2019-04-08 00:48:38 UTC (rev 430)
+++ pkg/CHNOSZ/man/diagram.Rd	2019-04-11 09:00:12 UTC (rev 431)
@@ -26,7 +26,7 @@
     contour.method = "edge",
     # colors
     col = par("col"), col.names = par("col"), fill = NULL,
-    fill.NA = "slategray1", limit.water = TRUE,
+    fill.NA = "gray80", limit.water = TRUE,
     # 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,
@@ -134,8 +134,10 @@
 \section{2-D diagrams}{
 On 2-D diagrams, the fields represent the species with the highest equilibrium activity.
 \code{fill} determines the color of the predominance fields, \code{col} that of the boundary lines.
-By default, \code{\link{heat.colors}} are used to fill the predominance fields in diagrams on the screen plot device.
-\code{fill} can be any color specification, or the word \samp{rainbow}, \samp{heat}, \samp{terrain}, \samp{topo}, or \samp{cm}, indicating a palette from \pkg{grDevices}.
+The default of NULL for \code{fill} produces transparent predominance fields.
+\code{fill} can be any \code{\link{colors}}, or the word \samp{rainbow}, \samp{heat}, \samp{terrain}, \samp{topo}, or \samp{cm}, indicating a palette from \pkg{grDevices}.
+Starting with \R version 3.6.0, \code{fill} can be the name of any available HCL color palette, matched in the same way as the \code{palette} argument of \code{\link{hcl.colors}}.
+
 \code{fill.NA} gives the color for empty fields, i.e. points for which NA values are present, possibly by using \code{\link{equilibrate}} at extreme conditions (see \code{test-diagram.Rd}).
 \code{fill.NA} is also used to specify the color outside the water stability limits on Eh-pH or pe-pH diagrams, when \code{limit.water} is TRUE.
 Note that the default for \code{fill.NA} is automatically changed to \samp{transparent} when \code{add} is TRUE.



More information about the CHNOSZ-commits mailing list