在每个方面更改选项

发布于 2024-09-07 20:00:21 字数 424 浏览 0 评论 0原文

我使用 ggplot2 中的构面来绘制大量基因的表达分布。我的绘图命令非常通用:

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

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

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

有没有办法让我在每个方面设置图的选项?

p 对象中进行挖掘并没有发现任何我可以使用的东西,尽管我可能遗漏了一些东西!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凹づ凸ル 2024-09-14 20:00:21

您可以使用具有无限范围和不同面的填充颜色的geom_rect

这已在此处的解决方案中完成:有条件地使用facet_grid更改面板背景?

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

This has been done in a solution here: Conditionally change panel background with facet_grid?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文