Skip to content

Commit

Permalink
plotProfile() handles units better (issue 1403)+
Browse files Browse the repository at this point in the history
+ this should improve plot,ctd-method also, of course.  The problem came
up in fixing another issue in which axis labels for unitless things were
getting "[]" appended on the end, which looked like a weird cabalistic
box on the plot (as it does, in this commit message, with the font I'm
using in my terminal!).

I am reasonably assured that the fix is OK, from inspection of the "git
diff" output and from the 1403 test suite.
  • Loading branch information
dankelley committed May 8, 2018
1 parent b1b4327 commit e3356bc
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions R/misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -2224,8 +2224,8 @@ resizableLabel <- function(item, axis="x", sep, unit=NULL, debug=getOption("oceD
abbreviated <- bquote("T"*.(L)*degree*"C"*.(R))
} else {
##message("unit given for temperature")
full <- bquote(.(var)*.(L)*.(unit)*.(R))
abbreviated <- bquote("T"*.(L)*.(unit)*.(R))
full <- bquote(.(var)*.(L)*.(unit[[1]])*.(R))
abbreviated <- bquote("T"*.(L)*.(unit[[1]])*.(R))
}
} else if (item == "conductivity mS/cm") {
var <- gettext("Conductivity", domain="R-oce")
Expand All @@ -2239,7 +2239,7 @@ resizableLabel <- function(item, axis="x", sep, unit=NULL, debug=getOption("oceD
## unitless form
var <- gettext("Conductivity Ratio", domain="R-oce")
unit <- gettext("unitless", domain="R-oce")
full <- bquote(.(var)*.(L)*.(unit)*.(R))
full <- bquote(.(var)*.(L)*.(unit[[1]])*.(R))
abbreviated <- bquote("C")
} else if (item == "conservative temperature") {
var <- gettext("Conservative Temperature", domain="R-oce")
Expand Down Expand Up @@ -2279,35 +2279,35 @@ resizableLabel <- function(item, axis="x", sep, unit=NULL, debug=getOption("oceD
full <- bquote(.(var)*.(L)*Tu*.(R))
abbreviated <- bquote(phantom()^3*H*.(L)*Tu*.(R))
} else {
full <- bquote(.(var)*.(L)*.(unit)*.(R))
abbreviated <- bquote(phantom()^3*H*.(L)*.(unit)*.(R))
full <- bquote(.(var)*.(L)*.(unit[[1]])*.(R))
abbreviated <- bquote(phantom()^3*H*.(L)*.(unit[[1]])*.(R))
}
} else if (item == "nitrate") {
var <- gettext("Nitrate", domain="R-oce")
if (is.null(unit)) {
full <- bquote(.(var)*.(L)*mu*mol/kg*.(R))
abbreviated <- bquote(N*O[3]*.(L)*mu*mol/kg*.(R))
} else {
full <- bquote(.(var)*.(L)*.(unit)*.(R))
abbreviated <- bquote(N*O[3]*.(L)*.(unit)*.(R))
full <- bquote(.(var)*.(L)*.(unit[[1]])*.(R))
abbreviated <- bquote(N*O[3]*.(L)*.(unit[[1]])*.(R))
}
} else if (item == "nitrite") {
var <- gettext("Nitrite", domain="R-oce")
if (is.null(unit)) {
full <- bquote(.(var)*.(L)*mu*mol/kg*.(R))
abbreviated <- bquote(N*O[2]*.(L)*mu*mol/kg*.(R))
} else {
full <- bquote(.(var)*.(L)*.(unit)*.(R))
abbreviated <- bquote(N*O[2]*.(L)*.(unit)*.(R))
full <- bquote(.(var)*.(L)*.(unit[[1]])*.(R))
abbreviated <- bquote(N*O[2]*.(L)*.(unit[[1]])*.(R))
}
} else if (item == "oxygen") {
var <- gettext("oxygen", domain="R-oce")
if (is.null(unit)) {
full <- bquote(.(var))
abbreviated <- bquote(O[2])
} else {
full <- bquote(.(var)*.(L)*.(unit)*.(R))
abbreviated <- bquote(O[2]*.(L)*.(unit)*.(R))
full <- bquote(.(var)*.(L)*.(unit[[1]])*.(R))
abbreviated <- bquote(O[2]*.(L)*.(unit[[1]])*.(R))
}
} else if (item == "oxygen saturation") {
var <- gettext("Oxygen saturation", domain="R-oce")
Expand All @@ -2331,17 +2331,17 @@ resizableLabel <- function(item, axis="x", sep, unit=NULL, debug=getOption("oceD
full <- bquote(.(var)*.(L)*mu*mol/kg*.(R))
abbreviated <- bquote(P*O[4]*.(L)*mu*mol/kg*.(R))
} else {
full <- bquote(.(var)*.(L)*.(unit)*.(R))
abbreviated <- bquote(P*O[4]*.(L)*.(unit)*.(R))
full <- bquote(.(var)*.(L)*.(unit[[1]])*.(R))
abbreviated <- bquote(P*O[4]*.(L)*.(unit[[1]])*.(R))
}
} else if (item == "silicate") {
var <- gettext("Silicate", domain="R-oce")
if (is.null(unit)) {
full <- bquote(.(var)*.(L)*mu*mol/kg*.(R))
abbreviated <- bquote(Si*O[4]*.(L)*mu*mol/kg*.(R))
} else {
full <- bquote(.(var)*.(L)*.(unit)*.(R))
abbreviated <- bquote(Si*O[4]*.(L)*.(unit)*.(R))
full <- bquote(.(var)*.(L)*.(unit[[1]])*.(R))
abbreviated <- bquote(Si*O[4]*.(L)*.(unit[[1]])*.(R))
}
} else if (item == "fluorescence") {
var <- gettext("Fluorescence", domain="R-oce")
Expand All @@ -2350,16 +2350,16 @@ resizableLabel <- function(item, axis="x", sep, unit=NULL, debug=getOption("oceD
full <- bquote(.(var))
abbreviated <- full
} else {
full <- bquote(.(var)*.(L)*.(unit)*.(R))
abbreviated <- bquote("Fluor."*.(L)*.(unit)*.(R))
full <- bquote(.(var)*.(L)*.(unit[[1]])*.(R))
abbreviated <- bquote("Fluor."*.(L)*.(unit[[1]])*.(R))
}
} else if (item == "spice") {
var <- gettext("Spice", domain="R-oce")
if (is.null(unit)) {
full <- bquote(.(var)*.(L)*kg/m^3*.(R))
abbreviated <- full
} else {
full <- bquote(.(var)*.(L)*.(unit)*.(R))
full <- bquote(.(var)*.(L)*.(unit[[1]])*.(R))
abbreviated <- full
}
} else if (item == "S") {
Expand Down Expand Up @@ -2422,7 +2422,7 @@ resizableLabel <- function(item, axis="x", sep, unit=NULL, debug=getOption("oceD
} else if (item == "frequency cph") {
var <- gettext("Frequency", domain="R-oce")
unit <- gettext("cph", domain="R-oce")
abbreviated <- full <- bquote(.(var)*.(L)*.(unit)*.(R))
abbreviated <- full <- bquote(.(var)*.(L)*.(unit[[1]])*.(R))
} else if (item == "spectral density m2/cph") {
var <- gettext("Spectral density", domain="R-oce")
full <- bquote(.(var)*.(L)*m^2/cph*.(R))
Expand All @@ -2437,7 +2437,7 @@ resizableLabel <- function(item, axis="x", sep, unit=NULL, debug=getOption("oceD
abbreviated <- full
} else {
oceDebug(debug, "unit \"", unit, "\" given\n")
full <- bquote(.(item)*.(L)*.(unit)*.(R))
full <- bquote(.(item)*.(L)*.(unit[[1]])*.(R))
abbreviated <- full
}
}
Expand Down

0 comments on commit e3356bc

Please sign in to comment.