简体   繁体   中英

How to graph multiple vertically offset density functions

I have a time series of univariate distributions that I'd like to visualize more compactly. i know how to add multiple density functions to the same set of axes, but I'd like to vertically offset each function to get show the evolution of the distribution through time.

ggplot is great for this type of stuff (here just using the same distro):

library(ggplot2)
ggplot(df, aes(x=x, y=values, color=ind)) + geom_line() + facet_wrap(~ ind, ncol=1)

在此处输入图片说明

And the toy data I used:

df <- stack(setNames(replicate(5, dnorm((-30:30)/10), s=F), letters[1:5]))
df$x <- ave(df$value, df$ind, FUN=seq_along)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM