如何用增加波长绘制波浪?
我正在看一堆电磁频谱图,并意识到它们显示的波实际上从未与图中给定的波长相对应。例如,红外波长的波长(lambda = 800 nm)应比X射线时的波长长800倍(lambda = 1 nm)。
如何绘制R中的波,以使波长与指定波长成正比增加?即f(x)= lambda和f(n * x)= n * lambda
简单示例,只是在电磁频谱的一小部分上:
library(ggplot2)
# Make a simple dataset
max.x <- 800 # Maximum wavelength in nanometers (nm) to show
steps <- 10000 # More steps make plotting smooter
waveforms <- as.data.frame(matrix(data=NA, nrow=steps+1, ncol=2, dimnames=list(NULL, c("x", "y"))))
waveforms$x <- seq(0,max.x, by=max.x/steps)
# We can make a wave with periods that increase easily
waveforms$y <- sin(sqrt(waveforms$x))
ggplot()+
geom_line(data=waveforms, aes(x=x, y=y), color="red")+
scale_x_continuous("Wavelength in nanometers (nm)")
频谱的低端不比上端的波长短800倍。什么是将波长成比例的实际公式?
I was looking at a bunch of electromagnetic spectrum diagrams and realized that the wave they show never actually corresponds with the given wavelengths in the diagram. For example, the wavelength of the wave at infrared (lambda = 800 nm) should appear 800 times longer than the wavelength at X-ray (lambda = 1 nm).
How can I plot a wave in r such that the wavelength increases proportional to the specified wavelength? i.e. f(x) = lambda and f(n * x) = n * lambda
Simple example just over a small part of the electromagnetic spectrum:
library(ggplot2)
# Make a simple dataset
max.x <- 800 # Maximum wavelength in nanometers (nm) to show
steps <- 10000 # More steps make plotting smooter
waveforms <- as.data.frame(matrix(data=NA, nrow=steps+1, ncol=2, dimnames=list(NULL, c("x", "y"))))
waveforms$x <- seq(0,max.x, by=max.x/steps)
# We can make a wave with periods that increase easily
waveforms$y <- sin(sqrt(waveforms$x))
ggplot()+
geom_line(data=waveforms, aes(x=x, y=y), color="red")+
scale_x_continuous("Wavelength in nanometers (nm)")
...but just eyeballing the graph, a wavelength at the low end of the spectrum isn't 800 times shorter than a wavelength at the upper end. What is the actual formula that would make the wavelengths proportional?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您需要波长的倒数累积总和(显然您必须跳过0,因为否则您的累积总和将是无限的):
I think you need the cumulative sum of the reciprocal of wavelength (obviously you have to skip 0 because otherwise your cumulative sum would be infinite):