0

I have a R plot of the following sort

regionalPlot <- ggplot(data = analyzed) + 
                geom_polygon(aes(x = long, y = lat, fill = income, group = group), color = "white") + 
                coord_fixed(1.3) +
                theme_bw()

The plot is generated by plotting the longitude and latitudes of a certain region grouped by the region name, and the region is being filled by some data value for that region (say income). This value is provided to the fill attribute as well for geom_polygon as fill=value.

However, I have 2 extra conditioning parameters say state_tax and sales_tax, both of which have true/false values. I want to fill the polygons using the same values, but by choosing a color scale based on the two conditioning parameters. So here I'll have 4 such combinations

state_tax == 'true' and sales_tax == 'true'
state_tax == 'true' and sales_tax == 'false'
state_tax == 'false' and sales_tax == 'true'
state_tax == 'false' and sales_tax == 'false'

Essentially I am looking for a way such that all states with a the same combination of values for state and sales tax, should be colored in different shades of same color interpolated by the value of income.

Can anybody point me to a way which would allow me to do this? Let me know in the comments if more information is needed.

Abhishek
  • 438
  • 1
  • 6
  • 16
  • Can you post your data? – camille Jun 12 '18 at 15:54
  • https://gist.github.com/ayenpure/330fea57029796d28b51ece41021032f This is the data I am working with, the fields mentioned in the question had been modified to present a simpler usecase, but here `income -> value` and `state_tax/sales_tax -> over_mean, over_standard` I use this data and perform an inner join on `region` with the states data sourced using instructions from this link http://eriqande.github.io/rep-res-web/lectures/making-maps-with-R.html – Abhishek Jun 12 '18 at 17:57
  • [See here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) on how you can post an R question that is easy for folks to help with. That includes the data we would need to work with and *all* your code being in the post, not as links – camille Jun 12 '18 at 18:49

0 Answers0