r/RStudio • u/melinda_r • 59m ago
Coding help Help with choropleth map colors!!
Hello! I'm trying to create a choropleth map in R using plotly but I'm having a hard time adjusting the color scale setting. My main issue is that there is only one country with a high number of n_studies so the map is quite hard to look at (the numbers range from 0 to 35). Here's my code:
# light grey boundaries
l <- list(color = toRGB("grey"), width = 0.5)
# specify map projection/options
g <- list(
showframe = FALSE,
showcoastlines = FALSE,
projection = list(type = 'Mercator')
)
fig2 <- plot_geo(all_data)
fig2 <- fig2 %>% add_trace(
z = ~n_studies, color = ~n_studies, colors = "Blues",
text = ~COUNTRY, locations = ~country_code, marker = list(line = l)
)
fig2 <- fig2 %>% colorbar(title = 'Number of studies', orientation = "h", y = -0.01)
fig2 <- fig2 %>% layout(
geo = g
)
fig2Any suggestions on how I can change the color scale setting so each interval is a bit more distinct? I was thinking of maybe using a specific color for each interval (e.g., 0-5, 5-10, etc.), not sure if that makes sense.
Thank you so much!!

