当使用眼镜包时,绘图返回R中的不连续线(带有间隙)

问题描述 投票:1回答:1

关于解决方案的最新消息: 在plot()命令中设置参数gap = F. library(spectacles) spectra(your_data) <- sr_no ~ ... ~ 350:2500 # turn your data frame to Spectra* object with the spectrum range of your interest plot(your_data, gaps = F) # return plot with no gaps or line discontinuously

#

我必须使用Spectra *对象并使用与此类似的代码进行绘图,只需通过我的数据更改内置“australia”数据框:

library(spectacles)    
data(australia)     
spectra(australia) <- sr_no ~ ... ~ 350:2500    
s <- cut(australia, wl =c(-1*450:500, -1*1800:2050))    
plot(s)    

我在R中的情节不连续地返回,如下图所示。数据框的尺寸为150行,3156列。当我将df减少到1800列时问题仍然存在。

有谁有同样的问题?你能建议一个解决方案吗?非常感谢你提前!

r spectra
1个回答
0
投票

请耐心等待,因为通过可视化解释我的问题要比发表评论容易得多。您要删除此数据还是要删除部分数据?见下面的例子。

s1 <- cut(australia, wl =c(-1*450:500, -1*1800:2050))
plot(s, gap=TRUE)

Spectral minus 450:500 & 1800:2050

或者,您可以将示例用于R中的帮助文件。

library(ggplot)
data(australia)
spectra(australia) <- id ~ ... ~ 500:1800 # changed the range

r <- melt_spectra(australia)
australia$fact <- sample(LETTERS[1:3], size = nrow(australia), replace = TRUE)
r <- melt_spectra(australia, attr = 'fact')
p <- ggplot(r) + geom_line(aes(x=wl, y=nir, group=id, colour=fact)) + theme_bw()
print(p)

Spectral image from 500:1800

另外,您可以进行部分分析。

s <- as(cut(australia, wl = 1*450:550), 'Spectra') 
plot(s)

subset of spectra

© www.soinside.com 2019 - 2024. All rights reserved.