【问题标题】:Use ggplot2 to make a scatterplot with categorical axes使用 ggplot2 制作带有分类轴的散点图
【发布时间】:2013-06-25 21:09:45
【问题描述】:

我有一个如下所示的数据集:

region    expression    species/gene
reg1      4             humanA
reg1      5             humanB
reg1      4             ratA
reg1      6             ratB
reg2      3             humanA
reg2      5             humanB
reg2      8             ratA
reg2      2             ratB

我想在 x 轴上绘制区域 1-n,在 y 轴上绘制表达式值,按物种/基因的值进行颜色编码。我还想通过每个物种/基因组绘制趋势线,并在边缘显示 r 值。理想情况下,我会使用某种格式

ggplot(data, aes(x=xvar, y=yvar)) +
geom_point(shape=1) +    
geom_smooth(method=lm) +
geom_point(shape=19, alpha=1/4) 

但我太笨了,无法弄清楚如何将它与我的数据纠缠在一起。提前致谢!

【问题讨论】:

    标签: r ggplot2 regression scatter-plot


    【解决方案1】:

    试试这个例子:

    library(ggplot2)
    ggplot(dat,aes(x=region,y=expression,
       group=species.gene,color=species.gene)) + 
      geom_line() 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-02-16
      • 2020-09-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-25
      • 2012-02-14
      • 1970-01-01
      相关资源
      最近更新 更多