-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stat_label_peaks() etc. with transformed wavelength scales #14
Comments
Thanks for raising the issue! I never tried this! :-( |
Had a very quick look. The function that computes colours from wavelengths I think is internally receiving as input negative wavelength values because of how the reverse scale works. Should be rather easy to fix. I will check in the morning. |
@nist-zack The problem is now fixed in GitHub. You can update package 'photobiology' from https://aphalo.r-universe.dev by running: install.packages("photobiology", repos = c("https://aphalo.r-universe.dev", "https://cloud.r-project.org")) The error was triggered by a function in package 'photobiology', not in 'ggspectra'. |
This fix does not solve problems with other transformation. All calls to
|
@nist-zack I should properly fix this problem with transformed scales. This could involve relatively large edits to several of the stats. It may take a week or two before I get this fixed. I will tell here when the fix is done. Meanwhile, you can use library(ggspectra)
ggplot(sun.spct) +
geom_line() +
stat_peaks(vjust=-1, span = 31, color = "red", geom = "text",
aes(label = stage(after_stat = after_stat(x)))) +
scale_x_reverse() |
@nist-zack I implemented a simple manual approach, that I hope to be able to automate in the future. It works by applying a function that the user can supply. I edited After installing the development version of 'ggspectra' with: install.packages("ggspectra", repos = c("https://aphalo.r-universe.dev", "https://cloud.r-project.org")) One can use code like this: ggplot(sun.spct) +
geom_line() +
stat_label_peaks(vjust=-1, span = 31, color = "red",
x.label.transform = abs) +
scale_x_reverse() or ggplot(sun.spct) +
geom_line() +
stat_label_peaks(vjust=-1, span = 31, color = "red",
x.label.transform = function(x) {10^x}) +
scale_x_log10() and get corect labels. This feature may change before the next release. |
Thank you for temporary modification for this package. It works normally now. |
I am trying to plot a reserved x-axis for spectrum plot, but stat_label_peaks() seems not support for the reverse plot. Is there any way to do this?
The warning message shows like following:
Warning message:
Computation failed in
stat_label_peaks()
.Caused by error in
color_of.numeric()
:! all(ifelse(is.na(x), Inf, x) > 0) is not TRUE
The text was updated successfully, but these errors were encountered: