Closed admahood closed 3 years ago
Thanks for trying out basemaps
. Not sure since I don't see your code but I guess this stems from ggplot
s axis expansion behavior which is the default for any ggplot
. Here a reproducible example for a basemap without the expansion:
library(ggplot2)
library(basemaps)
data(ext)
set_defaults(map_service = "osm", map_type = "topographic")
gg <- basemap_ggplot(ext)
#default ggplot2 behavior
gg
# with expanion reduced to 0 for both axis
gg + scale_x_continuous(expand = c(0,0)) + scale_y_continuous(expand = c(0,0))
Does that solve the issue?
And in case the issue is regarding ggplot2
plot margins and their removal, here a minimal example of the same map without any white space around it:
gg + scale_x_continuous(expand = c(0,0)) + scale_y_continuous(expand = c(0,0)) +
labs(x=NULL, y=NULL) +
theme(axis.line = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank(),
axis.title = element_blank(),
axis.ticks.length = unit(0, "pt"), #length of tick marks
legend.position = "none",
panel.background = element_blank(),
panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
plot.background = element_blank(),
plot.margin = unit(c(0,0,0,0),"mm"))
I think that solves it. Thanks!
In ggplot, there is a border of blank space when I use basemaps::basemap_gglayer or basemaps::basemap_ggplot. No matter what I do, the map refuses to go all the way to the edge of the plot border. Any way to get rid of this? it basically prevents me from being able to use this package for my visualizations. Other than this, I love the package!