Watts-College / cpp-529-fall-2021

https://watts-college.github.io/cpp-529-fall-2021/
0 stars 0 forks source link

Lab 05: Tips about getting dark colors to show up on chloropleth #11

Open mtwelker opened 2 years ago

mtwelker commented 2 years ago

Prof. @AntJam-Howell , I have two chloropleth maps that use the "RdBu" palette and the same number of breaks, but on one of them the lowest values show up nice and visible in dark red, and in the other they show up in pale pink. Do you know why, or can you tell me how to force the lowest amounts to show up in dark red?

Here's my code and output:

tm_shape( denver, bbox=bb ) + 
  tm_polygons( col="mhv.change", n=7, style="quantile", palette="RdBu", midpoint = 0 ) +
  tm_layout( "Denver, CO MSA", title.position=c("left","top"), title.size = 1.1,
             legend.position = c("left", "bottom"))

image

tm_shape( denver, bbox=bb ) + 
  tm_polygons( col="mhv.growth", n=7, style="quantile", palette="RdBu", midpoint = 0 ) +
  tm_layout( "Denver, CO MSA", title.position=c("left","top"), title.size = 1.1,
             legend.position = c("left", "bottom"))

image

The first one was originally only showing pink for the lowest values as well. I changed the number of breaks a few times and then all of a sudden the low values became dark red. So I don't want to mess with it anymore. But even though I've changed the number of breaks on the second one to try to replicate that, nothing seems to make a difference.

I know this is not critical for the assignment, but if you have any tips, I'd appreciate it. Thanks!

Michelle

AntJam-Howell commented 2 years ago

@mtwelker You would have to manually specify the colors to get exactly what you want rather than relying on R to assign the colors based on values. You could discretize the mhv.growth variable using quantcut into say deciles, and from there assign a specific color to each decile.

Best,

mtwelker commented 2 years ago

Thank you!