aligning tick maks with coord_map and ggplot

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

aligning tick maks with coord_map and ggplot

Andy Bunn-3
Hi all, given the map below is there an easy way to align the tick marks and text with the graticule? Many thanks, Andy

p1 <- ggplot() + borders("world", colour="gray50", fill="gray50")
p1 <- p1 + coord_map("ortho", orientation = c(40, -110, 0),
                     xlim=c(-133,-96),ylim=c(17,54))
p1


_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: aligning tick maks with coord_map and ggplot

zuzana zajkova
Hi Andy,

try the geom_sf (not sure now but probably you would need the dev. version
of ggplot2).
Check http://ggplot2.tidyverse.org/reference/ggsf.html

library(maps)
world1 <- sf::st_as_sf(map('world', plot = FALSE, fill = TRUE))
ggplot() + geom_sf(data = world1)

Projected:
ggplot() +
  geom_sf(data = world1, colour="gray50", fill="gray50") +
  coord_sf(crs="+proj=ortho +y_0=0 +lon_0=-110 +lat_0=40", xlim=c(-2000000,
500000), ylim=c(-1800000, 2000000)) +
  scale_x_continuous(breaks=seq(-140, -100, 10)) +
  scale_y_continuous(breaks=seq(10, 60, 10))

Best,

Zuzana

________________________________________

*Zuzana Zajkov√°*
PhD. student
Department of Evolutionary Biology, Ecology and Environmental Sciences |
Vertebrates
Faculty of Biology | University of Barcelona
Av. Diagonal 643, 08028  Barcelona, Spain
Email: [hidden email]

On 13 November 2017 at 20:40, Andy Bunn <[hidden email]> wrote:

> Hi all, given the map below is there an easy way to align the tick marks
> and text with the graticule? Many thanks, Andy
>
> p1 <- ggplot() + borders("world", colour="gray50", fill="gray50")
> p1 <- p1 + coord_map("ortho", orientation = c(40, -110, 0),
>                      xlim=c(-133,-96),ylim=c(17,54))
> p1
>
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: aligning tick maks with coord_map and ggplot

Andy Bunn-3
Wonderful thanks!

From: zuzana zajkova <[hidden email]>
Date: Tuesday, November 14, 2017 at 2:45 AM
To: Andy Bunn <[hidden email]>
Cc: R-sig-Geo <[hidden email]>
Subject: Re: [R-sig-Geo] aligning tick maks with coord_map and ggplot

library(maps)
world1 <- sf::st_as_sf(map('world', plot = FALSE, fill = TRUE))
ggplot() + geom_sf(data = world1)

Projected:
ggplot() +
  geom_sf(data = world1, colour="gray50", fill="gray50") +
  coord_sf(crs="+proj=ortho +y_0=0 +lon_0=-110 +lat_0=40", xlim=c(-2000000, 500000), ylim=c(-1800000, 2000000)) +
  scale_x_continuous(breaks=seq(-140, -100, 10)) +
  scale_y_continuous(breaks=seq(10, 60, 10))

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo