我想把下面的图片并排绘制好吗?
library(ggplot2)
library(patchwork)
# Plot the DEMs
p1 <- ggplot(dem %>% as.data.frame(xy = TRUE)) +
geom_raster(aes(x = x, y = y, fill = `10m_BA`)) +
scale_fill_gradientn(colors = terrain.colors(100))
p2 <- ggplot(dem30 %>% as.data.frame(xy = TRUE)) +
geom_raster(aes(x = x, y = y, fill = `10m_BA`)) +
scale_fill_gradientn(colors = terrain.colors(100))
# Combine the plots side by side
combined_plot <- p1 + p2 + plot_layout(ncol = 2, guides = "collect")
# Display the combined plot
combined_plot
字符串
的数据
我如何分享y轴和图例?
1条答案
按热度按时间mum43rcc1#
您可以使用
facet_wrap
和pivot_longer
,如下所示字符串
的数据