我有一个看起来像这样的数据框:
Samp1 Samp2 Samp3 Samp4 Samp5
Gene1 84.1 45.2 34.3 54.6 76.2
Gene2 94.2 12.4 68.0 75.3 24.8
Gene3 29.5 10.5 43.2 39.5 45.5
...
我正在尝试创建一个散点图,其中 x 轴是样本(Samp1-5),y 轴是行(Gene1-3 等),但我希望绘制每一行的数据作为同一情节上的不同颜色。
关于如何在 R 中做到这一点的任何想法?我非常愿意在 R 中使用 ggplot2、lattice、car 或任何其他包。
最佳答案
这是 ggplot2
的解决方案:
数据:
dat <- read.table(text="Samp1 Samp2 Samp3 Samp4 Samp5
Gene1 84.1 45.2 34.3 54.6 76.2
Gene2 94.2 12.4 68.0 75.3 24.8
Gene3 29.5 10.5 43.2 39.5 45.5", header = TRUE)
剧情:
library(ggplot2)
ggplot(stack(dat), aes(x = ind, y = values, colour = rownames(dat))) +
geom_point()
关于r - 为 R 中的多行创建散点图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13463294/