Closed
Description
I'm not sure if what I'm experiencing is the same problem as this one, again with incomplete labeling of the four positions of latitude and longitude:
library(ggplot2) library(sf) library(rnaturalearth) # Data: coast <- ne_coastline(scale = 50, returnclass = "sf") crs_pr <- "+proj=longlat +lon_0=180 +datum=WGS84 +no_defs" coast1 = coast |> st_break_antimeridian(lon_0 = 180) |> st_transform(crs_pr) ggplot(coast1)+ geom_sf()+ coord_sf(expand = FALSE, xlim = c(st_bbox(coast1)['xmin'], st_bbox(coast1)['xmax']), label_axes = list(top = 'E',bottom = "E", left="N",right="N") )
The labeled line for latitude is not crossed with the panel boundary.
When a little unreasonable adjustment is made (slightly limiting the range of x), everything works fine:
ggplot(coast1)+ geom_sf()+ coord_sf(expand = FALSE, xlim = c(st_bbox(coast1)['xmin']+5, st_bbox(coast1)['xmax']-5), label_axes = list(top = 'E',bottom = "E", left="N",right="N") )
It happens even with `expand = FALSE` set, which is weird.
Originally posted by @Breeze-Hu in #2985
This is a similar problem for raster plotting. Even without some projection transformations (compared to the previously mentioned geom_sf data).
library(ggplot2)
library(terra)
library(tidyterra)
#Example data downloaded from NOAA
https://psl.noaa.gov/mddb2/makePlot.html?variableID=1570
or
https://psl.noaa.gov/tmp/mddb2/_H5mqysfuv/subset.nc
data <- rast('Path')
ggplot()+
geom_spatraster(data = data,aes(fill = sst))+
scale_fill_viridis_c()+
coord_sf(expand = FALSE,
label_axes = list(top = 'E',bottom = "E", left="N", right="N"))
Metadata
Metadata
Assignees
Labels
No labels