逐面更改选项 [英] Change options on a per-facet basis

查看:48
本文介绍了逐面更改选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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,...)

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

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

但是,其中一些基因比其他基因更重要.例如,突出显示那些是转录因子(TFs)的基因真的很酷.一种方法是让我更改与TF对应的每个构面上的颜色标题框,背景色或类似颜色.

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?

p对象中进行挖掘并没有打开我可以使用的任何内容,尽管我可能丢失了一些东西!

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

推荐答案

您可以在无限范围内使用geom_rect,并且填充颜色随切面的不同而变化.

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

这篇关于逐面更改选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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