I would like to plot a geographical map with n numbers of squares according to the frequency of a disease within a county. Like this one here:

But I couldn’t figure out how to do this with R or qGIS.
Thanks for y’all help.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First write a little function called ‘stackbox’ that plots (using “rect”) the squares for the stack in the right place.
Here’s the first line of that function:
Then call that function for every county that has cases.
Where exactly were you stuck in the process?
Here’s the function in full:
Example:
To do this on a map, you need the sp and maptools packages, and a shapefile or other geospatial data source that has your data in it:
I’ve picked colours that look a bit like your original. Note that the boxes are in plot coordinates, so I had to make them 0.1 of a degree. You may wish to transform your map to a euclidean projection (using spTransform from package:gdal) and then they’ll be in those units and properly square.
Doing nice text labels like in your original would be tricky though…