Closed
Description
I'm working with ggplot2
and geom_sf
at the moment to create some maps, but I can't get the axis labels to re-position to the right using the position
argument within scale_y_continuous
as I would with other geometry types (e.g. geom_polygon
in the example below). Is this intentional or just not supported yet for geom_sf
?
library(sf)
library(ggplot2)
library(dplyr)
nc = st_read(system.file("gpkg/nc.gpkg", package="sf"))
# axis labels still on left
ggplot() + geom_sf(aes(fill = AREA),data=nc) + scale_y_continuous(position='right')
# Convert layer to sp and fortify
nc2 = as(nc,'Spatial')
nc2@data$id = rownames(nc2@data)
nc2 = fortify(nc2) %>% left_join(nc2@data)
# axis labels correctly moved to the right
ggplot() + geom_polygon(aes(x=long,y=lat,group=group,fill=AREA),data = nc2) +
scale_y_continuous(position='right') + coord_equal()
Metadata
Metadata
Assignees
Labels
No labels