Home > Blockchain >  us states plot in R with election results
us states plot in R with election results

Time:01-20

I have plotted a figure of the US states in R.

Here is the very simple code:

library(usmap) 
library(ggplot2)
plot_usmap(region = 'states')

And here is the resulting figure: enter image description here

Note that I think the lines between the states look good in white, so color="white" fixes that. You may also notice that you typically don't specify the actual color in the dataframe - you can specify that via scale_fill_manual(values=...). In your case, you can use scale_fill_identity().

For your data, just make sure the "States" column in your dataset is renamed "state" and it should work.

  •  Tags:  
  • Related