我正在尝试将test1,一个用tmap制作的地图,和test2,一个用ggplot2制作的用cowplot::plot_grid绘制的地块结合起来。
library(ggplot2)
library(tmap)
library(cowplot)
library(ggplotify)
test2 <-ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + geom_point()
data("World")
test1 <- tm_shape(World) + tm_polygons("HPI")
plot_grid(test1,test2)tmap似乎与牛仔情节不兼容:
在as_grob.default(绘图)中:无法将类tmap的对象转换为grob
使用时同样的问题
tmap::tmap_arrange(test1,test2)Tmap_arrange中的错误(test1,test2):并非所有参数都是tmap对象
我还试图使用ggplotify中的"as.grob“这样的函数来转换tmap,
test3 <- as.grob(test1)但没有运气“UseMethod("as.grob")中的错误:没有将”as.grob“应用于类"tmap”对象的适用方法。“
有什么建议吗?
谢谢!
发布于 2021-04-02 07:48:29
是的,我最近增加了tmap_grob来做这项工作。
library(ggplot2)
library(tmap)
library(cowplot)
library(ggplotify)
test2 <-ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + geom_point()
data("World")
tm <- tm_shape(World) + tm_polygons("HPI")
test1 <- tmap_grob(tm)
plot_grid(test1,test2)https://stackoverflow.com/questions/66659389
复制相似问题