r - 为 R 中的多行创建散点图

标签 r plot ggplot2 lattice scatter-plot

我有一个看起来像这样的数据框:

        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()

enter image description here

关于r - 为 R 中的多行创建散点图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13463294/

相关文章:

plot - Julia :当我有情节时如何找到最佳拟合曲线/方程?

javascript - 从 JSON 在单个 Highcharts 图中绘制多个系列

r - 使用 R 中的工具提示绘制县级数据

r - 是否可以像 ggplot 一样使图形绘图可移植?

r - ggplot2:在 ROC 图上使用 scale_x_reverse

r - 带变量列表的聚合函数

r - 如何使用 grImport 导入的图形作为 ggplot2 中的轴刻度标签(使用网格函数)?

R:在 ggplot 中使用 rollmean 会在最后产生错误的下降

r - R 的 NODF 图中没有显示轴标签

html - 如何使用 rvest 在网页中抓取 <br>-delimited 内容?