您好,我希望此气泡图图例中的气泡以图表中使用的绿色颜色着色。我想出了如何使用简单的颜色(例如这里的橙色)自定义颜色,但我不确定如何使用 viridis 颜色或更一般的任何调色板覆盖 aes。
指南(大小=guide_legend(覆盖.aes = 列表(颜色=“橙色”)))
# Libraries
library(ggplot2)
library(dplyr)
# Get the world polygon and extract UK
library(maps)
UK <- map_data("world") %>% filter(region=="UK")
# Get a data frame with longitude, latitude, and size of bubbles (a bubble = a city)
data <- world.cities %>% filter(country.etc=="UK")
# virids package for the color palette
library(viridis)
# Do bubble map and use viridis as color palette
ggplot() +
geom_polygon(data = UK, aes(x=long, y = lat, group = group), fill="grey", alpha=0.3) + …Run Code Online (Sandbox Code Playgroud)