[CHNOSZ-commits] r931 - in pkg/CHNOSZ: . R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Jun 21 08:28:58 CEST 2025
Author: jedick
Date: 2025-06-21 08:28:57 +0200 (Sat, 21 Jun 2025)
New Revision: 931
Modified:
pkg/CHNOSZ/DESCRIPTION
pkg/CHNOSZ/R/util.plot.R
pkg/CHNOSZ/inst/NEWS.Rd
pkg/CHNOSZ/man/util.plot.Rd
Log:
Handle logarithmic axis scales in label.plot() and label.figure()
Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION 2025-06-20 07:12:34 UTC (rev 930)
+++ pkg/CHNOSZ/DESCRIPTION 2025-06-21 06:28:57 UTC (rev 931)
@@ -1,6 +1,6 @@
-Date: 2025-06-20
+Date: 2025-06-21
Package: CHNOSZ
-Version: 2.2.0-1
+Version: 2.2.0-2
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/util.plot.R
===================================================================
--- pkg/CHNOSZ/R/util.plot.R 2025-06-20 07:12:34 UTC (rev 930)
+++ pkg/CHNOSZ/R/util.plot.R 2025-06-21 06:28:57 UTC (rev 931)
@@ -37,15 +37,19 @@
if(4 %in% side) thermo.axis(NULL,side = 4,lwd = lwd, plot.line = !plot.box)
}
-label.plot <- function(x, xfrac = 0.07, yfrac = 0.93, paren = FALSE, italic = FALSE, ...) {
+label.plot <- function(label, xfrac = 0.07, yfrac = 0.93, paren = FALSE, italic = FALSE, ...) {
# Make a text label e.g., "(a)" in the corner of a plot
# xfrac, yfrac: fraction of axis where to put label (default top right)
# paren: put a parenthesis around the text, and italicize it?
- if(italic) x <- substitute(italic(a), list(a = x))
- if(paren) x <- substitute(group('(', a, ')'), list(a = x))
- if(italic | paren) x <- as.expression(x)
+ if(italic) label <- bquote(italic(.(label)))
+ if(paren) label <- bquote(group("(", .(label), ")"))
pu <- par('usr')
- text(pu[1]+xfrac*(pu[2]-pu[1]), pu[3]+yfrac*(pu[4]-pu[3]), labels = x, ...)
+ x <- pu[1]+xfrac*(pu[2]-pu[1])
+ y <- pu[3]+yfrac*(pu[4]-pu[3])
+ # Conversion for logarithmic axes
+ if(par("xlog")) x <- 10^x
+ if(par("ylog")) y <- 10^y
+ text(x, y, labels = label, ...)
}
usrfig <- function() {
@@ -60,15 +64,20 @@
return(list(x = xfig, y = yfig))
}
-label.figure <- function(x, xfrac = 0.05, yfrac = 0.95, paren = FALSE, italic = FALSE, ...) {
+label.figure <- function(label, xfrac = 0.05, yfrac = 0.95, paren = FALSE, italic = FALSE, ...) {
# Function to add labels outside of the plot region 20151020
f <- usrfig()
# Similar to label.plot(), except we have to set xpd here
opar <- par(xpd = NA)
- if(italic) x <- substitute(italic(a), list(a = x))
- if(paren) x <- substitute(group('(',a,')'), list(a = x))
- if(italic | paren) x <- as.expression(x)
- text(f$x[1]+xfrac*(f$x[2]-f$x[1]), f$y[1]+yfrac*(f$y[2]-f$y[1]), labels = x, ...)
+ if(italic) label <- bquote(italic(.(label)))
+ if(paren) label <- bquote(group("(", .(label), ")"))
+ # Calculate location for label
+ x <- f$x[1] + xfrac * (f$x[2] - f$x[1])
+ y <- f$y[1] + yfrac * (f$y[2] - f$y[1])
+ # Conversion for logarithmic axes
+ if(par("xlog")) x <- 10^x
+ if(par("ylog")) y <- 10^y
+ text(x, y, labels = label, ...)
par(opar)
}
Modified: pkg/CHNOSZ/inst/NEWS.Rd
===================================================================
--- pkg/CHNOSZ/inst/NEWS.Rd 2025-06-20 07:12:34 UTC (rev 930)
+++ pkg/CHNOSZ/inst/NEWS.Rd 2025-06-21 06:28:57 UTC (rev 931)
@@ -15,6 +15,18 @@
\newcommand{\Cp}{\ifelse{latex}{\eqn{C_P}}{\ifelse{html}{\out{<I>C<sub>P</sub></I>}}{Cp}}}
\newcommand{\DG0}{\ifelse{latex}{\eqn{{\Delta}G^{\circ}}}{\ifelse{html}{\out{Δ<I>G</I>°}}{ΔG°}}}
+\section{Changes in CHNOSZ version 2.2.0-2 (2025-06-21)}{
+
+ \itemize{
+
+ \item \code{label.plot()} and \code{label.figure()} now handle
+ logarithmic scales for x and y axes.
+
+ }
+
+}
+
+
\section{Changes in CHNOSZ version 2.2.0 (2025-06-20)}{
\subsection{OBIGT DATABASE FORMAT}{
Modified: pkg/CHNOSZ/man/util.plot.Rd
===================================================================
--- pkg/CHNOSZ/man/util.plot.Rd 2025-06-20 07:12:34 UTC (rev 930)
+++ pkg/CHNOSZ/man/util.plot.Rd 2025-06-21 06:28:57 UTC (rev 931)
@@ -24,10 +24,10 @@
thermo.axis(lab = NULL, side = 1:4, line = 1.5, cex = par("cex"),
lwd = par("lwd"), col = par("col"), grid = "", col.grid = "gray",
plot.line = FALSE)
- label.plot(x, xfrac = 0.07, yfrac = 0.93, paren = FALSE,
+ label.plot(label, xfrac = 0.07, yfrac = 0.93, paren = FALSE,
italic = FALSE, ...)
usrfig()
- label.figure(x, xfrac = 0.05, yfrac = 0.95, paren = FALSE,
+ label.figure(label, xfrac = 0.05, yfrac = 0.95, paren = FALSE,
italic = FALSE, ...)
water.lines(eout, which = c("oxidation","reduction"),
lty = 2, lwd = 1, col = par("fg"), plot.it = TRUE)
@@ -58,7 +58,7 @@
\item{...}{further arguments passed to \code{par} or \code{mtext}}
\item{lab}{character, axis label}
\item{line}{numeric, margin line on which to place axis label or plot title}
- \item{x}{character, label to place on plot}
+ \item{label}{character, label to place on plot}
\item{xfrac}{numeric, fractional location on \eqn{x}{x}-axis for placement of label}
\item{yfrac}{numeric, fractional location on \eqn{y}{y}-axis for placement of label}
\item{paren}{logical, add parentheses around label text?}
@@ -90,8 +90,9 @@
\code{NA} is returned for any diagram for variables that can not be processed (including diagrams with more than 2 variables).
\code{label.plot} and \code{label.figure} add identifying text within the plot region and figure region.
-The value given for \code{x} is made into a label, optionally italicized and with parentheses (like \ifelse{latex}{\eqn{(a)}}{\ifelse{html}{\out{(<i>a</i>)}}{(a)}}).
-The location of the label is controlled by \code{xfrac} and \code{yfrac} (the fractional coordinates of either the plot or figure region), and \code{...} can include other parameters such as \code{cex} and \code{adj} that are passed to \code{\link{text}}.
+The value given for \code{label} is used, optionally italicized and with parentheses (like \ifelse{latex}{\eqn{(a)}}{\ifelse{html}{\out{(<i>a</i>)}}{(a)}}).
+The location of the label is controlled by \code{xfrac} and \code{yfrac} (the fractional coordinates of either the plot or figure region),
+and \code{...} can include other parameters such as \code{cex} and \code{adj} that are passed to \code{\link{text}}.
\code{usrfig} returns the limits of the figure region in \dQuote{user} coordinates (i.e. the limits of the plot region, from \code{\link{par}("usr")}).
It is a supporting function for \code{label.figure} but is also useful for other circumstances where information must be added at a particular location in a figure.
More information about the CHNOSZ-commits
mailing list