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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Oct 12 15:02:44 CEST 2018


Author: jedick
Date: 2018-10-12 15:02:43 +0200 (Fri, 12 Oct 2018)
New Revision: 333

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/diagram.R
   pkg/CHNOSZ/inst/NEWS
   pkg/CHNOSZ/man/diagram.Rd
Log:
diagram(): add 'family', 'font', 'bold', 'italic' arguments


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2018-10-09 05:17:30 UTC (rev 332)
+++ pkg/CHNOSZ/DESCRIPTION	2018-10-12 13:02:43 UTC (rev 333)
@@ -1,6 +1,6 @@
-Date: 2018-10-09
+Date: 2018-10-11
 Package: CHNOSZ
-Version: 1.1.3-40
+Version: 1.1.3-41
 Title: Thermodynamic Calculations and Diagrams for Geo(bio)chemistry
 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	2018-10-09 05:17:30 UTC (rev 332)
+++ pkg/CHNOSZ/R/diagram.R	2018-10-12 13:02:43 UTC (rev 333)
@@ -29,7 +29,8 @@
   col=par("col"), col.names=par("col"), fill=NULL,
   fill.NA="slategray1", limit.water=TRUE,
   # field and line labels
-  names=NULL, format.names=TRUE, adj=0.5, dy=0, srt=0,
+  names=NULL, format.names=TRUE, bold=FALSE, italic=FALSE,
+  font=par("font"), family=par("family"), adj=0.5, dy=0, srt=0,
   # title and legend
   main=NULL, legend.x=NA,
   # plotting controls
@@ -253,7 +254,11 @@
     if(all(grepl("_", names))) is.pname <- TRUE
     if(format.names & !is.pname) {
       exprnames <- as.expression(names)
-      for(i in seq_along(exprnames)) exprnames[[i]] <- expr.species(exprnames[[i]])
+      for(i in seq_along(exprnames)) {
+        exprnames[[i]] <- expr.species(exprnames[[i]])
+        if(bold) exprnames[[i]] <- substitute(bold(a), list(a=exprnames[[i]]))
+        if(italic) exprnames[[i]] <- substitute(italic(a), list(a=exprnames[[i]]))
+      }
       names <- exprnames
     }
 
@@ -334,7 +339,7 @@
             }
             # also include y-offset (dy) and y-adjustment (labels bottom-aligned with the line)
             # .. and srt (string rotation) 20171127
-            text(xvalues[imax], plotvals[[i]][imax] + dy[i], labels=names[i], adj=c(thisadj, 0), cex=cex.names, srt=srt[i])
+            text(xvalues[imax], plotvals[[i]][imax] + dy[i], labels=names[i], adj=c(thisadj, 0), cex=cex.names, srt=srt[i], font=font, family=family)
           }
         } else legend(x=legend.x, lty=lty, legend=names, col=col, cex=cex.names, lwd=lwd, ...)
       }
@@ -501,7 +506,7 @@
         # plot field labels
         # the cex argument in this function specifies the character 
         # expansion of the labels relative to the current
-        if(!is.null(names) & any(inames)) text(namesx, namesy, labels=names[inames], cex=cex.names, col=col.names[inames])
+        if(!is.null(names) & any(inames)) text(namesx, namesy, labels=names[inames], cex=cex.names, col=col.names[inames], font=font, family=family)
         return(list(namesx=namesx, namesy=namesy, inames=which(inames)))
       }
 

Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS	2018-10-09 05:17:30 UTC (rev 332)
+++ pkg/CHNOSZ/inst/NEWS	2018-10-12 13:02:43 UTC (rev 333)
@@ -1,4 +1,4 @@
-CHANGES IN CHNOSZ 1.1.3-40 (2018-10-09)
+CHANGES IN CHNOSZ 1.1.3-41 (2018-10-11)
 ---------------------------------------
 
 THERMODYNAMIC DATA
@@ -70,6 +70,11 @@
 - diagram(): numeric 'names' now indicates subset of species names to
   include as labels on the plot.
 
+- diagram(): new argument 'family' to select the font family for species
+  names (labels on the plot). New arguments 'bold' and 'italic' apply to
+  formatted names (e.g. chemical formulas), and 'font' applies to those
+  without formatting.
+
 BUG FIXES
 
 - Fix a bug where subcrt()$reaction$coeffs was incorrect for reactions

Modified: pkg/CHNOSZ/man/diagram.Rd
===================================================================
--- pkg/CHNOSZ/man/diagram.Rd	2018-10-09 05:17:30 UTC (rev 332)
+++ pkg/CHNOSZ/man/diagram.Rd	2018-10-12 13:02:43 UTC (rev 333)
@@ -27,7 +27,8 @@
     col=par("col"), col.names=par("col"), fill=NULL,
     fill.NA="slategray1", limit.water=TRUE,
     # field and line labels
-    names=NULL, format.names=TRUE, adj=0.5, dy=0, srt=0,
+    names=NULL, format.names=TRUE, bold = FALSE, italic = FALSE, 
+    font = par("font"), family = par("family"), adj=0.5, dy=0, srt=0,
     # title and legend
     main=NULL, legend.x=NA,
     # plotting controls
@@ -69,6 +70,10 @@
   \item{limit.water}{logical, set NA values beyond water stability limits?}
   \item{names}{character, names of species for activity lines or predominance fields}
   \item{format.names}{logical, apply formatting to chemical formulas?}
+  \item{bold}{logical, use bold formatting for names?}
+  \item{italic}{logical, use italic formatting for names?}
+  \item{font}{character, font type for names (has no effect if \code{format.names} is TRUE)}
+  \item{family}{character, font family for names}
   \item{adj}{numeric, adjustment for line labels}
   \item{dy}{numeric, y offset for line labels}
   \item{srt}{numeric, rotation for line labels}



More information about the CHNOSZ-commits mailing list