[R-sig-Geo] Reverse y-axis with geom_sf
Kent Johnson
kent3737 @end|ng |rom gm@||@com
Tue Mar 19 14:55:27 CET 2019
Hi,
I am working with data representing cells in a tissue sample with lines and
polygonal regions defined in the same space. The cells and polygons are
represented and manipulated as simple features objects and visualized using
ggplot2 and geom_sf. Mostly this works very well. The problem is that the
coordinate system of my data has the origin at the top left corner. For
data with no CRS, geom_sf puts the origin at the bottom left so all my
plots are inverted.
Is there a way to invert the y axis while staying within sf (or possibly
sp?) The only answers I have found involve extracting the coordinates from
the sf objects and inverting or plotting from the raw data. Maybe by
creating a CRS with the correct orientation?
For a very simple example with just a few vectors - the code below plots an
arrow pointing down; I would like to invert the y-axis so it points up.
library(sf)
library(ggplot2)
s1 <- rbind(c(9, 11), c(10, 10))
s2 <- rbind(c(11, 11), c(10, 10))
s3 <- rbind(c(10,14), c(10, 12), c(10,10))
mls <- st_multilinestring(list(s1,s2,s3))
ggplot(mls) + geom_sf()
Thank you for any help,
Kent Johnson
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list