0

I am trying to use plot_usmap to map a data frame with two columns - fips and change2 - where the values for change2 range from -34.7 to 91.5. When I run this code:

plot_usmap(regions = "counties", values = "change2", data = map, color = "white") + 
  scale_fill_gradient2(
    low = "red", mid = "grey", high = "dark green", name = "Change from SPLY", label = scales::percent) + 
  theme(legend.position = "right")

The legend gives the values as -3000 to +9000.

Why doesn't the legend match the values of change2? Is there a fix to this that I'm missing?

0

In case someone else happens to have this issue too, the answer is very obvious:

ggplot multiplies the values by 100 when label = scales::percent, so if your values have already been converted into percentages, then you will get percent*100.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.