1. Learn
  2. /
  3. Courses
  4. /
  5. Visualizing Geospatial Data in R

Exercise

Tidying up the legend and some final tweaks

Time for some final tweaks and then to save your plot.

Every element in your plot is a target for tweaks. Is it the right color? Is it the right size? Does it have intuitive labels? Your goal is to emphasize the data and de-emphasise the non-data elements.

We've got some ideas for this plot. Let's tweak a few things.

Instructions

100 XP
  • Make it clear what the color represents by adding title = "Median Income" and palette = "Greens" in the tm_fill() call, which will map income to a green color scale.
  • Add subtle borders to the tracts to make it more clear where their boundaries are by adding a tm_borders() layer with col = "grey60" and lwd = 0.5.
  • Make the neighborhood boundaries a little more important than tract boundaries by setting col = "grey40" and lwd = 2.
  • Add a data source credit using a tm_credits() call with first argument "Source: ACS 2014 5-year Estimates, \n accessed via acs package" and second argument position = c("right", "bottom").
  • Finally, save your plot as "nyc_income_map.png" using the tmap_save() function with arguments width = 4 and height = 7.