R + ggplot:如何在每个平面上更改选项 [英] R + ggplot: how to change options on a per-facet basis

查看:115
本文介绍了R + ggplot:如何在每个平面上更改选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在使用ggplot2中的方面来绘制大量基因中表达式的分布。我的绘图命令非常通用:

  p < -  ggplot(top_n,aes(x = value,fill = ptype)) 
p <-p + geom_density(alpha = 0.2)
p <-p + facet_wrap(〜probe,...)

它们只是根据 ptype 变量将top_n中的数据绘制为着色分布。它看起来很棒。



然而,其中一些基因比其他基因更重要。例如,突出那些是转录因子(TF)的基因是非常酷的。其中一种方法是将颜色标题框更改为与TF对应的每个方面或背景颜色或类似的东西。

有没有办法让我在每个方面设定地块的选项?



p 对象中挖掘并没有发现任何我可以使用的东西,尽管我可能会丢失你可以使用带有无限范围的 geom_rect 和一个填充项。

颜色从不同方面变化到不同。


Hi I'm using facets in ggplot2 to plot the distribution of expression in a large number of genes. My plotting commands are pretty generic:

p <- ggplot(top_n,aes(x=value,fill=ptype))
p <- p + geom_density(alpha = 0.2)
p <- p + facet_wrap(~probe,...)

they just plot the data in top_n as distributions coloured according to the ptype variable. It looks great.

Some of these genes, however, are more important than others. It would be really cool to highlight those genes which are transcription factors (TFs), for example. One way would be for me to change the colour title box over each facet corresponding to a TF, or the background colour, or something like that.

Is there a way for me to set options of the plots on a per-facet basis?

Digging around in the p object hasn't turned up anything I can use, though I'm probably missing something!

解决方案

You could use geom_rect with infinite extents and a fill colour that varies from facet to facet.

这篇关于R + ggplot:如何在每个平面上更改选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆