Open ndavis4904 opened 2 years ago
Try the code below. It's a bit different from yours, so you might want to try to incorporate, rather than adopt wholesale.
library(tidyr)
ggplot(CenDF, aes(fill=HHInc_HousePrice_Ratio)) +
geom_sf(color="white")+
coord_sf(xlim=c(-180, -65), ylim = c(20, 70))+
theme_void() + theme(panel.grid.major = element_line(colour = 'transparent')) +
scale_fill_distiller(palette="Reds", direction=-1, name="Estimate") +
labs(title="Median Home Value to Income", caption="Source: US Census/ACS5 2017") +
NULL
@ndavis4904 - if helpful, this is an example of a bounding box. You have data outside of the US (probably data from US territories like Guam), so the map will default to the full range of the data. You can do one of two things:
(1) filter out data points outside of your desired mapping area, then plot (2) add a bounding box to define the area visualized in the map
The bounding box commands will be different in each plotting package. Base plot() and uses the typical xlim and ylim arguments. ggplot uses the coord_sf() geom you see above. In ttmap you have to create an explicit bounding box object you pass to your plot function (you will see this in lab 3).
Here's an old video on using locator() to find bounding box values on your map: https://www.youtube.com/watch?v=jx5y0EdIUT4
Thanks. Both of these were a huge help.
Here is the code and output that I am working on:
ggplot(CenDF) + geom_sf(aes(fill = HHInc_HousePrice_Ratio), color = NA) + coord_sf(datum = NA) + labs(title = "House Value to Income Ratio", caption = "Source: US Census/ACS5 2017") + scale_fill_viridis(direction = -1)
Is there a way to remove all the extra space next to the United States? I've tried messing around with scale_x_continuous(), and scale_y_continuous() additions, but that ends up squishing everything really weird.