Issue merging maps
Vincius-Trevisan opened this issue · 5 comments
Hello everyone.
For the assignment 4, I ran into a problem.
It is not an error itself.
When I plot my soil-type map the legend is quite big, and takes half of the map space, I have been trying to change different features but it is not solving.
The same problem happens when all the plots are merged, the legends keep covering the map view, even when the size is changed.
Soil type ggplot code:
series_map <- ggplot()+
geom_sf(data = boundary_geoj, alpha = 0.5) +
geom_sf(data = series_sf, aes(fill = muname))+
scale_fill_viridis_d()+
theme(legend.position = "bottom",
legend.box = "horizontal"
)+
guides(fill = guide_legend(nrow = 4, byrow = TRUE))+
labs(fill = "Soil type")+
theme_map()
series_map
Merging code:
#| fig-width: 15
#| fig-height: 20
series_map + yield_map + elevation_map +
plot_annotation(title = "Soil series(a), corn yield (b), and elevation (c)",
tag_levels = "a",
tag_suffix = ")"
) &
theme(plot.title = element_text(hjust = 0.5, size = 30))
ggsave("../output/series_map.png",
width = 15,
height = 20,
limitsize = FALSE
)
Does someone have ideas on how to make it look better?
@Vincius-Trevisan what happens if you do theme(legend.position = "left")
?
I am also having issues with the legend being to large or not even showing at all and the actual field maps being small when I combine the maps
series_map + yield_map + elevation_map +
plot_annotation(title = "Soil Series (a), Corn Yield (b), and Elevation (c)",
tag_levels = "a",
tag_suffix = ")") +
theme(plot.title = element_text(hjust = 0.5, size = 20),
legend.position = "top")
@Vincius-Trevisan @ClintHerndon if the issue persists when you render it, and none of the potential fixes worked (e.g., changing the size of the figure output at the chunk level as we discussed in class, moving the legend to the right or left, etc), then please send me the rendered version (with the legends overlapping) and the individual figures (png files) for the maps that were overlapping.
I was having the same issue and tried different ways. Finally I gave up and made changes in 2 places:
- in static map (elevation and yield) used : theme(legend.position=" right")
- in combined plot chunk I used:
legend.key.size=unit(.5,"lines)+
theme(plot.margin= margin(t=1, unit="lines")
Overall maps became small, but according to ratio, all are same now.
I know it is not a great solution to offer, but at least it helps.