如何在ggplot2中为同一变量添加具有不同单位的第二个图例?

时间:2019-01-19 06:41:31

标签: r ggplot2

我用以下代码绘制了用开尔文表示的气温。现在,我想添加第二个图例,以摄氏度显示等效值。有可能吗?

library(ggplot2)
library(cptcity)

nc <- rotate(brick(x = fnl_20111128_00_00.nc,
                   var = "TMP_1000mb")))
df <- as.data.frame(rasterToPoints(nc))

ggplot() + 
  geom_raster(data = df,
              aes(x = x, y = y, fill = X1322438400),
              interpolate = T) +  
  scale_fill_gradientn(colours = cpt("ncl_precip2_17lev"), 
                       name = "T (K)",
                       na.value = "white")

Here is the wanted result.

0 个答案:

没有答案