cbeleites / hyperSpec

R package hyperSpec can now be found at https://github.com/r-hyperspec/hyperSpec
http://r-hyperspec.github.io/hyperSpec/
GNU General Public License v3.0
22 stars 11 forks source link

Questions regarding axis labels and `qplotspc()` function body #108

Closed eoduniyi closed 4 years ago

eoduniyi commented 4 years ago

Hello,

I had two questions related to hyperSpec plotting

Q1: Referencing the flu data set, does the x-axis label "lambda/nm" mean that lambda is used as the symbol for wavelength, and wavelength is measured in units of nm (i.e., "lambda (nm)")? Similarly, does the y-axis "I/a.u." mean that I used as a symbol for intensity, and intensity is measured in units of a.u. ("I (a.u.)")?

Q2: Doesn't setting the unlist parameter to FALSE within wl2i ensure that the length of the wl.range is never less than 1?

.
.
.
wl.range <- wl2i(x, wl.range, unlist = FALSE)

  x <- x [, , unlist(wl.range), wl.index = TRUE]

  df <- as.long.df(x, rownames = TRUE, na.rm = FALSE) # with na.rm trouble with wl.range

  ## ranges go into facets
  if (length(wl.range) > 1L) {
    tmp <- wl.range
    for (r in seq_along(tmp)) {
      tmp [[r]][TRUE] <- r
    }

    df$.wl.range <- rep(unlist(tmp), each = nrow(x))
  }

Also, please see subsection 4.3 within the README.md

GegznaV commented 4 years ago

Regarding Q1

"lambda/nm"

should be the same as "λ, nm"

("I (a.u.)")

The intensity in arbitrary units. Some times abbreviation is just "u." (units) that usually means the same as a.u.

eoduniyi commented 4 years ago

Thanks, @GegznaV that makes things clearer: I was used to seeing "λ (nm)" or "λ, nm"

GegznaV commented 4 years ago

There are some technical issues in writing Unicode symbols: they might get distorted on some computers/operating systems. Tex/Latex expressions are not directly supported in R. Sometimes it is tedious to write (and for readers to understand the code of) plot math expressions. There are hex and other codes for symbols (e.g., "\u3bb" is also λ, print it in R console). But in quick examples, the authors selected a more easy-to-understand way to write the expression (basing on an assumption that a reader has solid knowledge in spectroscopy).

bryanhanson commented 4 years ago

In practice many people will just display "nm" or "ppm" or "Hz" (or whatever is appropriate for that particular type of spectroscopy) for the x-axis label and not explicitly state that it is a wavelength or frequency. For the y-axis, I often just see "intensity" or "absorbance" etc. "a.u" is a little tricky: in some contexts it is "arbitrary units" and in others "absorbance units".

GegznaV commented 4 years ago

I didn't know about "absorbance units", but if one does not state exact units of measurement "absorbance units" and "arbitrary units" sound as synonyms in this context. Especially, one usually knows the context (fluorescence, absorbance, Raman, reflectance et. spectroscopy) then he or she can guess what are the units.ANd in well prepared scientific publications the abbreviations are explained in the description of the figure.

And I cannot recall if these abbreviations are defined somewhere in vignettes. Maybe it is worth doing?

ximeg commented 4 years ago

@GegznaV

And I cannot recall if these abbreviations are defined somewhere in vignettes. Maybe it is worth doing?

Could you please open a ticket for that so that it does not go throgh the cracks? Thanks!

ximeg commented 4 years ago

I did some research: according to table 19 in paragraph 45 of Unified Code for Units of Measure, arbitrary units should be abbreviated as "arb. U"

cbeleites commented 4 years ago

Q2: Doesn't setting the unlist parameter to FALSE within wl2i ensure that the length of the wl.range is never less than 1?

Yes, but it can be 1, and then the plot doesn't get wavelength facets (not even a single one).

GegznaV commented 4 years ago

@eoduniyi, could you explain, what issue are we solving here? Is it a bug or a possible bug? (Then the issue should be opened in https://github.com/r-hyperspec/hySpc.ggplot2/issues). Or could we just safely close this issue?

eoduniyi commented 4 years ago

@eoduniyi, could you explain, what issue are we solving here? Is it a bug or a possible bug? (Then the issue should be opened in https://github.com/r-hyperspec/hySpc.ggplot2/issues). Or could we just safely close this issue?

Yeah I will go ahead and close this