问题标签 [cowplot]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
r - Joining a dendrogram and a heatmap
I have a heatmap (gene expression from a set of samples):
(The left side gets cut off because of the plot.margin arguments I'm using but I need this for what's shown below).
Then I prune the row dendrogram according to a depth cutoff value to get fewer clusters (i.e., only deep splits), and do some editing on the resulting dendrogram to have it plotted they way I want it:
And I plot them together using cowplot's plot_grid:
Although the align='h' is working it is not perfect.
Plotting the un-cut dendrogram with map1.plot using plot_grid illustrates this:
The branches at the top and bottom of the dendrogram seem to be squished towards the center. Playing around with the scale seems to be a way of adjusting it, but the scale values seem to be figure-specific so I'm wondering if there's any way to do this in a more principled way.
Next, I do some term enrichment analysis on each cluster of my heatmap. Suppose this analysis gave me this data.frame:
What I'd like to do is plot this data.frame as a heatmap and place the cut dendrogram below it (similar to how it's placed to the left of the expression heatmap).
So I tried plot_grid again thinking that align='v' would work here:
First regenerate the dendrogram plot having it facing up:
Now trying to plot them together:
plot_grid doesn't seem to be able to align them as the figure shows and the warning message it throws:
What does seem to get close is this:
This is achieved after playing around with the scale parameter, although the plot comes out too wide. So again, I'm wondering if there's a way around it or somehow predetermine what is the correct scale for any given list of a dendrogram and heatmap, perhaps by their dimensions.
r - 自 ggplot2 更新以来 ggdraw 的问题
我用下面的代码做了一个图,但是,我最近注意到我的一些数据点没有包含它们应该包含的错误栏,所以我在编写它几个月后重新访问了这个代码。在这段时间里,ggplot2 得到了更新,现在我的代码中出现了我不知道如何修复的错误。下面详细介绍这些。
我的代码是:
当我运行这一切运行正常,直到我来到最后一行代码p13 <- ggdraw(switch_axis_position(p4, axis = 'x'))
然后我收到以下错误:
gt$grobs[[ixl]] 中的错误:尝试选择少于一个元素此外:警告消息:1:
panel.margin已弃用。请改用panel.spacing属性 2:删除 1 行包含缺失值 (geom_errorbarh)。
我不是经验丰富的编码员,所以我不确定如何解决这些错误。我没有在我的代码中使用 panel.margin,所以不确定如何将其更改为 panel.spacing。如果有人可以为此提供任何帮助以及gt$grobs[[ixl]]错误,我将不胜感激!
r - grid_plot + tikzDevice + 带有乳胶标记的共享图例
我一直在尝试关注如何为多个 ggplot2 制作共享图例。给定的示例按原样完美运行,但就我而言,我正在使用 tikzDevice 导出tikzpicture环境。主要问题似乎是图例键的宽度未被正确捕获grid_plot。
我想出了一个重现问题的最小 R 代码:
生成的 PDF 文件(编译 tmp.tex 后)如下所示:
我们可以观察到,第一个图例键(四)仅部分显示,图例键(八)完全不可见。我尝试更改tikz命令宽度无济于事。
另外,我怀疑问题背后的原因是 grid_plot 命令错误地测量了图例键的长度,如果它们包含乳胶标记。为了表明这是问题的原因,请考虑将 mpg2$cyl 的级别更改为以下内容:
这应该会产生以下带有完美图例的图:
请注意,上面的示例只是为了重现问题,而不是我想要做的。相反,我有四个图,我试图为它们使用一个共享的公共图例。
任何人都可以告诉我如何解决包含乳胶标记的图例问题?
顺便说一句,这是我的sessionInfo():
谢谢你们。
r - cowplot plot_grid 函数将表格绘制为图像和树状图
我正在尝试使用 cowplot 中的 plot_grid 函数制作一个自定义图,其中第一行有一个树状图,第二行有两个表(彼此相邻)。现在最终发生的是我的树状图和表格被绘制,但在两个单独的 PDF 上。有没有办法让它们都绘制在同一页面上?下面是我的代码片段:
用于聚类(hclust)的 dput 输出片段:
r - R:使用 ggplot2 + ggExtra + cowplot 绘图时删除边框
通过ggplot2 + ggExtra + cowplot组合图形时,我找不到不绘制外框的方法。我不确定我必须在哪里告诉 R,但怀疑问题出在 ggExtra 上。这是一个例子:

任何提示将不胜感激!












