R-Lum/Luminescence

Invalid 'ylim' value when using combine = FALSE

Closed this issue · 5 comments

Expected behaviour

Trim y axis to given values

Observed behaviour

Error message:

Error in plot.window(...) : invalid 'ylim' value

Running mini example

Setup: newest Luminescence Version (1st February 2018, master branch). I do not know if this error is included in the current CRAN version.

library(Luminescence)
data(ExampleData.BINfileData, envir = environment())

Risoe.BINfileData2RLum.Analysis(CWOSL.SAR.Data, pos=1) %>%
plot_RLum.Analysis(
  subset = list(recordType = "TL"),
  combine = FALSE, 
  xlim = c(0,100), 
  ylim = c(0, 200))

Error in plot.window(...) : invalid 'ylim' value

When changing to combine = TRUE it works as expected.

Perhaps related to issue #25

PS: The test file "tests/testthat/test_plot_Functions.R "did not test this case ...

The error is gone, but there is somewhere a side-effect. Look at the plots created by the code above (after your commit fixing the error). The first y-axis is going to 140, not 200, and curve #13 also. This was also visible in the traceback at the error I reported.

I would not call it a side effect, it is a wanted feature. If you look at the code, you will see that the functions reset the user input to the available minimum value. Why, because the function was designed as an overview plot.

In your example the setting ylim = c(0,200) means that the highest value is bigger than the highest value of curve 13. Thus, the value gets reset.

If this is the case, make a short note in the documentation, otherwise it is counterintuitive (IMHO).

Agreed