I have a polygon shape file named CROPS.shp
and the following key -
1 - Rice
2 - Wheat
3 - Corn
4 - Millets
I read the shape file using the rgdal
package into a variable named my_crops
. Now my_crops@data
has six different fields namely Y1
, Y2
, Y3
, Y4
, Y5
and Y6
. Each of these fields has values from 1 to 4.
So for example, the first few rows of crops@data
would be like
Y1 Y2 Y3 Y4 Y5 Y6
1 2 4 1 1 2
3 4 1 1 1 2
4 2 2 2 1 3
What do I want to do?
I want to have a page with 6 plots (2 rows, 3 columns), where the first plot would be based on the field Y1
, and the last plot would be based on the field Y6
. The colour of the plots (polygon shapes) should be based on the values 1 to 4, in each of the shapefile plots.
The plots should be accompanied by a single legend at the bottom of the page.
Do you mean something like this?