我正在尝试运行下面的代码,可以从https://lambda.gsfc.nasa.gov/data/cobe/firas/monopole_spec/firas_monopole_spec_v1.txt访问数据
#loading the data
cobe <- read.table("~/Downloads/cobe.txt", quote="\"")
frequency <- (cobe$V1)*29.979
spectrum <- cobe$V2
B_f <- function(frequency, t){
h <- 6.62607015e-34
c <- 299792458
k <- 1.380649e-23
spectrum <- ((2*h*frequency^3)/c^2)/exp((h*frequency)/k*t)-1
return(spectrum * 1e-9)
}
t <- 2.725
spectrum <- B_f(frequency,t)
library(ggplot2)
ggplot(data = data.frame(frequency, spectrum)) +
geom_line(aes(x = frequency, y = spectrum)) +
ggtitle("Blackbody spectrum at T = 2.725K \n with data from the COBE satellite") +
xlab("Frequency (GHz)") + ylab("Spectral Radiance (MJy/sr)") +
theme_classic()+
geom_point(aes(x = frequency, y = spectrum), color = 'red', size = 5)
我一直得到第一张图像(直线水平图),但我期待第二张图(BB曲线)output plot [2] expected plot。
1条答案
按热度按时间vltsax251#
根据您提供的源代码,我认为您进行了不必要的转换:
产生一个情节,以配合您的预期形象,我想?