首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将表格grob居中对齐到x轴标签

将表格grob居中对齐到x轴标签
EN

Stack Overflow用户
提问于 2021-01-22 00:44:45
回答 1查看 31关注 0票数 0

我窃取了下面的例子(原始发现的http://www.sthda.com/english/articles/24-ggpubr-publication-ready-plots/81-ggplot2-easy-way-to-mix-multiple-graphs-on-the-same-page/#align-plot-panels)。输出中心在图中对齐表格,但我希望将表格与上图的x轴标签对齐。做这件事最简单的方法是什么?

代码语言:javascript
复制
library("ggpubr")
library("grid")
library("gridExtra")
# Density plot of "Sepal.Length"
#::::::::::::::::::::::::::::::::::::::
density.p <- ggdensity(iris, x = "Sepal.Length", 
                       fill = "Species", palette = "jco")
# Draw the summary table of Sepal.Length
#::::::::::::::::::::::::::::::::::::::
# Compute descriptive statistics by groups
stable <- desc_statby(iris, measure.var = "Sepal.Length",
                      grps = "Species")
stable <- stable[, c("Species", "length", "mean", "sd")]
# Summary table plot, medium orange theme
stable.p <- ggtexttable(stable, rows = NULL, 
                        theme = ttheme("mOrange"))
p <- arrangeGrob(density.p, stable.p, 
                 ncol = 1,
                 heights = c(2, 1))
grid.draw(p)

这是输出。

这是我想要的输出(表格向右移动以与x轴标签对齐)。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-01-22 01:02:40

尝试使用patchwork

代码语言:javascript
复制
library(patchwork)
#Code
G <- density.p/stable.p

输出:

或者这样:

代码语言:javascript
复制
#Code 2
G <- density.p/(plot_spacer()+stable.p)

输出:

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65831927

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档