我有以下網格
plot_df_2=ggplot()
geom_contour_fill(data=df_2, aes(x=lon, y=lat, z=var), alpha=0.9)
scale_fill_steps(name = "", low = "#bdd7e7", high = "#08519c",
breaks = seq(0, 160, by = 10))
print(plot_df_2)

有沒有一種方法可以創建一個獨特的顏色條圖例,以便更好地比較這兩個圖?
每個圖的圖例應該具有相同的顏色和相關值。
在上面的兩個圖中,兩個圖中的最高(最低)值具有相同的顏色,但它們的大小不同。例如,是否可以為 plot_df_2 顯示較深的顏色?
uj5u.com熱心網友回復:
這是實作@Mamoun Benghezai 評論中描述的解決方案的一種方法:
library(tidyverse)
library(metR)
# Combine df1 and df2 to a single df ("df_table")
df_table <- map_df(.x = list("df_1" = df_1,
"df_2" = df_2),
.f = bind_rows,
.id = "src")
# Plot the combined dataset
plot_df_1 <- ggplot(df_table)
geom_contour_fill(aes(x=lon, y=lat, z=var), alpha=0.9)
scale_fill_steps(name = "", low = "#bdd7e7", high = "#08519c",
breaks = seq(0, 160, by = 10))
facet_wrap(~src)
print(plot_df_1)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/427631.html
