Reputation: 437
I want to plot a map showing crime frequency. I run the command:
tm_shape(trinidad) + tm_polygons("Crime_Total", palette = "Reds", colorNA = NULL, title = "Crime
Frequency")
and obtain this result
I have a few issues with this plot, though. As you can see, the majority of the areas are light red since only a few areas have extremely high frequencies. I would therefore like to have the map show a threshold value of 2500. Also, how can I get areas with frequency = 0 to show completely white and not light red?
I would envision my legend looking something like this, with the same color scheme applied to the map:
Crime Frequency white: 0 very light red: 0-500 light red: 500-1000 pinkish red: 1000-1500 red: 1500-2000 dark red: 2000-2500 very dark red: > 2500
I tried looking for a way to specify cutoffs in the tm_polygons function but I wasn't able to find a solution. Is there any way to manipulate the map to get my desired result?
Upvotes: 4
Views: 2219
Reputation: 8146
You can use the following code to modify the legend
tm_shape(trinidad) + tm_polygons("Crime_Total", style = "fixed", breaks=c(0,500,1000,1500,2000,2500,12000),
palette = "Reds", colorNA = NULL, title = "Crime Frequency")
To have the last class as >2500, you can use the highest value in your dataset.
Upvotes: 4