Could be a weird interaction from the ceramic package, but I'm getting weird behavior with repelled text & labels being plotted well off the extent when using the ylim or xlim argument in geom_spatial_text_repel() (in order to constrain the labels to a specific area on a map), but so far only when I use it in combination with a layer_spatial() basemap.
Reprex:
library(tidyverse)
library(sf)
library(ggspatial)
library(ceramic)
load_longlake_data()
basemap <- cc_location(loc = as(st_buffer(st_convex_hull(st_union(st_transform(longlake_depthdf, 4326))), .001), "Spatial"),
zoom = 12,
type = "mapbox.satellite")
ggplot() +
layer_spatial(data = basemap) +
geom_sf(data = longlake_depthdf %>%
st_transform(4326),
color = "red") +
geom_spatial_text_repel(
data = st_drop_geometry(longlake_depthdf),
aes(label = DEPTH,
x = LON,
y = LAT),
color = "red",
# Try to constrain labels
ylim = c(45.904, 45.900),
inherit.aes = FALSE
) +
coord_sf(datum = 4326,
expand = 0)
Could be a weird interaction from the
ceramic
package, but I'm getting weird behavior with repelled text & labels being plotted well off the extent when using theylim
orxlim
argument ingeom_spatial_text_repel()
(in order to constrain the labels to a specific area on a map), but so far only when I use it in combination with alayer_spatial()
basemap.Reprex:
Results in this: