Reverse y-axis with geom_sf
On Tue, Mar 19, 2019 at 1:54 PM Jes?s <gesusjl at gmail.com> wrote:
Hi Kent Did you try using the coord_flip function from ggplot? Cheers Jes?s
Yes, I did, coord_flip() doesn't work with geom_sf():
ggplot(mls) + geom_sf() + coord_flip()
Error: geom_sf() must be used with coord_sf() Thanks for the suggestion! Kent
El mar., 19 mar. 2019 a las 13:55, Kent Johnson (<kent3737 at gmail.com>) escribi?:
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]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
-- Jes?s