Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(ggplot2)
- foo <- expand.grid(
- chr = paste('chr', 1:3, sep = ''),
- pos = seq(1, 1e8, length.out = 1e3+1),
- sp = c('Sp A', 'Sp B', 'Sp C')
- )
- foo$density <- runif(nrow(foo))
- p1 <- ggplot(data = foo, aes(x = pos, y = density)) +
- geom_smooth(method = 'loess', span = 0.01, se = FALSE) +
- facet_grid(sp ~ chr) +
- theme_bw()
- p2 <- p1 + geom_ribbon(aes(ymin = 0, fill = chr, ymax = predict(loess(density ~ pos, span = 0.01))), alpha = 0.3)
- png(filename = '~/Desktop/wo_ribbon.png', width = 1000, height = 500)
- print(p1)
- dev.off()
- png(filename = '~/Desktop/w_ribbon.png', width = 1000, height = 500)
- print(p2)
- dev.off()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement