1

R-usmap: how to change the label to be smaller? How to put the label underneath the map? How to have the map margin space smaller? Thanks a lot!

enter image description here

Waldi
  • 39,242
  • 6
  • 30
  • 78
nancyruya
  • 83
  • 7

1 Answers1

2

You can put the legend at the bottom like this:

library(usmap)

df2 <- usmap::statepop
df2$diffProviderPerFFS <- runif(nrow(df2), -0.2, 0.5)

plot_usmap(data = df2, values  = "diffProviderPerFFS", color = "white") +
  scale_fill_continuous(name = "Provider Per 1000 FFS(2017-2016)", 
                        low="light green",
                        high="dark green", 
                        label = scales::comma) +
  theme(legend.position = "bottom")

enter image description here

Changing this will automatically create more space for your map to move into. However, in general, the best way to change the size of the legend relative to the nap is to make your plotting window bigger. Look what happens to the relative sizes when I shrink the same plot window down:

enter image description here

And now I make it take up my whole screen width:

enter image description here

This is because the legend stays the same size, but the map expands to fit the rest of the plotting window (it looks smaller in the last image because the whole picture had to be shrunk down to fit on this page.

Allan Cameron
  • 147,086
  • 7
  • 49
  • 87