我正在尝试重新创建这个山脊图:
https://i.stack.imgur.com/QAFs1.jpg
但是,我似乎无法让曲线出现在情节上,正如您可能已经猜到的那样,我对 r 很陌生,所以我几乎复制了https://bytefish.de/blog/timeseries_databases_5_visualization_with_ggridges /到达我所在的位置。
这是代码:
eustockmark_index <- fortify.zoo(EuStockMarkets)
eustockmark_index$Index=as.factor(eustockmark_index$Index)
eustockmark_index$Index=factor(eustockmark_index$Index,levels=c(1991,1992,1993,1994,1995,1996,1997,1998))
eustockmark_index$Index= trimws(eustockmark_index$Index)
eustockmark_index
ggplot(eustockmark_index, aes(x = `DAX`, y =`Index`,fill=..x..)) +
geom_density_ridges_gradient() +
labs(title = "DAX",
x = " ",
y = " ")+
scale_fill_viridis(option = "C")
另外,如果有人能解释为什么我的 Y 轴顶部有 NA,那将是了不起的。非常感谢!