2013-08-12 6 views

答えて

12

# example data: 
dat <- list(a=1:5,b=2:7,c=3:10) 
# get plotting: 
plot(unlist(dat),type="n",xlim=c(1,max(sapply(dat,length)))) 
mapply(lines,dat,col=seq_along(dat),lty=2) 
legend("topleft",names(dat),lty=2,col=seq_along(dat)) 

enter image description here

9

は疑問のggplotの答えのない完全ではないでしょう。

dat <- list(a=1:5,b=2:7,c=3:10) 
dat <- lapply(dat, function(x) cbind(x = seq_along(x), y = x)) 

list.names <- names(dat) 
lns <- sapply(dat, nrow) 
dat <- as.data.frame(do.call("rbind", dat)) 
dat$group <- rep(list.names, lns) 

library(ggplot2) 

ggplot(dat, aes(x = x, y = y, colour = group)) + 
    theme_bw() + 
    geom_line(linetype = "dotted") 

enter image description here

ggplot(dat, aes(x = x, y = y, colour = group)) + 
    theme_bw() + 
    geom_line(linetype = "dotted") + 
    facet_wrap(~ group) 
+0

'ダット$グループ<使用し、別のプロットに各ラインをプロットするには - 担当者(名(DAT)、LNS)'必ず名前の一致になるだろうしあなたのグループで。 – thelatemail

+0

@thelatemail私の答えを編集してください。 –

+0

あなたはそれ自身のプロットウィンドウに各グループを持つことができます。ファセットプロットのように。 – MySchizoBuddy

関連する問題