Экстент, цветовая гамма Viridis - PullRequest
0 голосов
/ 27 апреля 2020

Есть ли способ, которым я мог бы расширить (предварять) значение «прозрачный» в начале цветовой схемы Viridis? Или, может быть, отменить это так, чтобы каждое значение (скажем, ниже -30) было «прозрачным» цветом?

    plot.nme = paste0('PLOTS/','temphi_tomorrow_test.png')
pred <- ggplot() +
  geom_raster(data = nnmsk_df , aes(x = x, y = y, fill = var1.pred),interpolate = FALSE) + 
  annotate(geom="raster", x=ctry$x, y=ctry$y, alpha=.2,fill = scales::colour_ramp(c("#00000000","grey"))(ctry[,3])) +
  theme_void() + # Empty theme without axis lines and texts
  scale_fill_viridis(option = "viridis", direction = 1,name="Maximum temperature (°C)", limits = c(-30,30),breaks=c(-30,-25,-20,-15,-10,-5,0,5,10,15,20,25,30), na.value = "transparent") +
  geom_text(aes(label = dfdat$temphi),x = dfdat$Longitude,y = dfdat$Latitude,size=0.6,col="#ffffff",
            hjust = -0.01,
            vjust = 0.01) +
  geom_point(shape = 1)  

pred_snow <- pred +
  geom_contour(aes(x = x, y = y, z = var1.pred),data = nnmsk_df, na.rm = TRUE,bins = 6,colour = "white",  alpha = 0.2,size=0.1) +
  theme(
    panel.background = element_rect(fill = "transparent", colour = NA),
    plot.background = element_rect(fill = "transparent", colour = NA),
    legend.background = element_rect(fill = "transparent", colour = NA),
    legend.box.background = element_rect(fill = "transparent", colour = NA),
    legend.position = c(0.5, 0.3),
    legend.key.size = unit(0.4, "cm"),
    legend.key.width = unit(0.4, "cm"),
    legend.key.height = unit(0.1, "cm"),
    legend.direction = "horizontal",
    legend.title = element_text(color = "white", size = 4),
    legend.text = element_text(colour="white",size=3)
  ) 

pred_snow
ggsave(plot.nme, height = graph_height , width = graph_height * aspect_ratio,bg = "transparent",dpi = 300)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...