##=====================##
##(1) Literature example after Mooney et al. (2013)
##(1.1) create matrix
m <- matrix(
data = c(seq(400, 800, 50), rep(1, 9)), ncol = 2)
##(1.2) set plot function to reproduce the
##literature figure
p <- function(m) {
plot(x = m[, 1], y = m[, 2])
polygon(
x = c(m[, 1], rev(m[, 1])),
y = c(m[, 2], rep(0, nrow(m))))
for (i in 1:nrow(m)) {
lines(x = rep(m[i, 1], 2), y = c(0, m[i, 2]))
}
}
##(1.3) plot curves
par(mfrow = c(1,2))
p(m)
p(convert_Wavelength2Energy(m))
##=====================##
##(2) Another example using density curves
##create dataset
xy <- density(
c(rnorm(n = 100, mean = 500, sd = 20),
rnorm(n = 100, mean = 800, sd = 20)))
xy <- data.frame(xy$x, xy$y)
##plot
par(mfrow = c(1,2))
plot(
xy,
type = "l",
xlim = c(150, 1000),
xlab = "Wavelength [nm]",
ylab = "Luminescence [a.u.]"
)
plot(
convert_Wavelength2Energy(xy),
xy$y,
type = "l",
xlim = c(1.23, 8.3),
xlab = "Energy [eV]",
ylab = "Luminescence [a.u.]"
)
Run the code above in your browser using DataLab