r - 在同一张纸上安排 ggplot 时出现错误,包括 grobs
问题描述
我在使用以下语法时遇到了问题,我认为这可能是因为我使用的是分面图。
g1<-ggplot(tfp) +
aes(x = `año`, y = TFP_cd) +
geom_line(size = 1.25, colour = "#cb181d") +
labs(x = "Years", y = TeX("$\\ln(TFP)$"), title = "Cobb Douglas TFP Evolution", subtitle = "Mean TFP") +
theme_light()+theme(plot.title = element_text(face="bold", size=18),
plot.subtitle = element_text(size = 15))+scale_x_continuous(breaks = breaks_extended(n=8))
g2 <- ggplot(tfpr) +
aes(x = `año`, y = TFP_cd, fill = rama, colour = rama) +
geom_line(size = 1.25) +
scale_fill_brewer(palette = "Set1") +
scale_color_brewer(palette = "Set1") +
labs(x = "Year", y =TeX("$\\ln(TFP)$"), title = "Cobb Douglas TFP Evolution", subtitle = "On ISIC 1 level") +
theme_light() +
theme(legend.position = "none") +
facet_wrap(~(rama), scales = "free")+scale_x_continuous(breaks = breaks_extended(n=8))+
theme(plot.title = element_text(face="bold", size=18),plot.subtitle = element_text(size = 15))+
theme(strip.text.x = element_text(size = 12, color = "black", face = "bold"))
g3 <- ggplot(tfpv) +
aes(x = año, y = TFP_cd, colour = size) +
geom_line(size = 1.25) +
scale_color_brewer(palette = "Set1") +
labs(x = "Year", y =TeX("$\\ln(TFP)$"), title = "Cobb Douglas TFP Evolution", subtitle = "On Andean Community Sale Size Classification") +
theme_light()+scale_x_continuous(breaks = breaks_extended(n=8))+
theme(plot.title = element_text(face="bold", size=18),plot.subtitle = element_text(size = 14))+
theme(strip.text.x = element_text(size = 12, color = "black", face = "bold"))
所以我有包library(ggpubr)
,我一直这样做:
ggarrange(g1,g2,g3,
ncols=1, nrows=3)
但它给了我这个错误:
> ggarrange(g1,g2,g3,
+ ncols=1, nrows=3)
Warning messages:
1: In as_grob.default(plot) :
Cannot convert object of class numeric into a grob.
2: In as_grob.default(plot) :
Cannot convert object of class numeric into a grob.
还有这张图。我只需要该图,但需要 1 列 3 行。(垂直的)
提前致谢。
解决方案
推荐阅读
- c++ - GLSL 计算着色器不适用于大输入
- xamarin - Xamarin.Forms:在代码中关闭 DatePicker,当使用自定义渲染器时
- c++ - C++ 在 std::unordered_set 中获取类型键
- python - 如何根据字典和另一列之间的匹配创建新的 df 列
- centos - X-debugger 在查看 PHP 服务器端脚本中的变量时显示意外更改
- reactjs - 切换到 TypeScript 后的依赖问题
- python-3.x - 碰撞点是否有等效的颜色功能?
- mongodb - 如何在codeigniter中用“like”查询MongoDB?
- c# - DbContext 作为控制器构造函数中的依赖注入
- android - 卸载应用程序时,我不希望删除 SqlLite 数据库