【发布时间】:2018-11-14 23:03:31
【问题描述】:
我看过example1 和How to overlay density plots in R? 和Overlapped density plots in ggplot2 关于如何制作密度图。我可以使用第二个链接中的代码制作密度图。但是我想知道如何在ggplot 或plotly 中制作这样的图表?
我查看了所有示例,但无法解决我的问题。
我有一个带有基因表达leukemia data description 的玩具数据框,其中的列指的是 2 组个体
leukemia_big <- read.csv("http://web.stanford.edu/~hastie/CASI_files/DATA/leukemia_big.csv")
df <- data.frame(class= ifelse(grepl("^ALL", colnames(leukemia_big),
fixed = FALSE), "ALL", "AML"), row.names = colnames(leukemia_big))
plot(density(as.matrix(leukemia_big[,df$class=="ALL"])),
lwd=2, col="red")
lines(density(as.matrix(leukemia_big[,df$class=="AML"])),
lwd=2, col="darkgreen")
【问题讨论】:
标签: r ggplot2 plotly density-plot