I made this map and it's nearly perfect except for the inset map has this pesky white borer around it. I would like for the inset to just have the black line border of the actual panel border, but not that white background that's coming along with it. Additionally, my panel.grid
element is not displaying above the land mass I have plotted, and would like for it to display above the land mss (pictured in the main map in light gray). I have my panel.grid = element_line(color = "darkgray")
in my main map, but it's still not displaying the way I intended. The same goes for my scale bar and my north arrow. Here is a screenshot of my plot:
And this is the code that I used to generate my map:
MainMap <- ggplot(QOI) +
geom_sf(aes(fill = quadID)) +
scale_fill_manual(values = c("#6b8c42",
"#70b2ae",
"#d65a31")) +
labs(fill = "Quadrants of Interest",
caption = "Figure 1: Map depicting the quadrants in the WSDOT project area as well as other quadrants of interest in the Puget Sound area.")+
ggtitle("WSDOT Project Area and Quadrants of Interest") +
geom_sf(data = BCWA_land) +
xlim (-123.1, -121.4) +
ylim (47.0, 48.45) +
theme_bw()+
theme(panel.grid = element_line(color = "darkgray"),
legend.text = element_text(size = 11, margin = margin(l = 3), hjust = 0),
legend.position = c(0.95, 0.1),
legend.justification = c(0.85, 0.1),
legend.background = element_rect(colour = "#3c4245", fill = "#f4f4f3"),
axis.title = element_blank(),
plot.title = element_text(face = "bold", colour = "#3c4245", hjust = 0.5, margin = margin(b=10, unit = "pt")),
plot.caption = element_text(face = "italic", colour = "#3c4245", margin = margin(t = 7), hjust = 0, vjust = 0.5))
MainMap
InsetRect <- data.frame(xmin=-123.2, xmax=-122.1, ymin=47.02, ymax=48.45)
InsetMap <- ggplotGrob( ggplot( quads) +
geom_sf(aes(fill = "")) +
scale_fill_manual(values = c("#eefbfb"))+
geom_sf(data = BCWA_land) +
scale_x_continuous(expand = c(0,0), limits = c(-124.5, -122.0)) +
scale_y_continuous(expand = c(0,0), limits = c(47.0, 49.5)) +
geom_rect(data = InsetRect,aes(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax),
color="#3c4245",
size=1.25,
fill=NA,
inherit.aes = FALSE) +
theme_bw()+
theme(legend.position = "none",
panel.grid = element_blank(),
axis.title = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank(),
panel.background = element_blank()))
InsetMap
Figure1 <- MainMap +
annotation_custom(grob = InsetMap, xmin = -122.2, xmax = -121.3,
ymin = 47.75, ymax = 48.5) +
scalebar(x.min = -122.7, x.max = -122.5, y.min = 46.95, y.max = 47.1, location = "bottomright",
transform = TRUE, dist = 10, dist_unit = "km", st.size = 2, st.bottom = TRUE)
Figure1
In the inset map code, I had set the panel.background = element_blank()
so I'm not sure why I'm still getting a white background/border around my inset.
Please let me know if you need the data that I used to generate these maps. It's a larger file and so the character limit on SO limits what I can put up. Even if I trim the data down, because they are polygon shape files a single data row is pretty cumbersome to share.
Any insight would be much appreciated!