@@ -106,3 +106,33 @@ test_that("works with a blank theme", {
106106 expect_length(l $ data , 2 )
107107 expect_equivalent(l $ data [[1 ]]$ line $ color , " transparent" )
108108})
109+
110+ test_that(" resolves overlapping axis ticks" , {
111+ skip_if_not_installed(" sf" )
112+ skip_if_not_installed(" rnaturalearth" )
113+ skip_if_not_installed(" maps" )
114+
115+ world <- rnaturalearth :: ne_countries(returnclass = " sf" )
116+
117+ # filter the world sf object down to canada
118+ canada <- rnaturalearth :: filter(world , name == " Canada" )
119+ # coerce cities lat/long data to an official sf object
120+ cities <- sf :: st_as_sf(
121+ maps :: canada.cities ,
122+ coords = c(" long" , " lat" ),
123+ crs = 4326
124+ )
125+ # A PROJ4 projection designed for Canada
126+ # http://spatialreference.org/ref/sr-org/7/
127+ # http://spatialreference.org/ref/sr-org/7/proj4/
128+ moll_proj <- " +proj=moll +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84
129+ +units=m +no_defs"
130+ # perform the projections
131+ canada <- sf :: st_transform(canada , moll_proj )
132+ cities <- sf :: st_transform(cities , moll_proj )
133+ # plot with geom_sf()
134+ p <- ggplot() +
135+ geom_sf(data = canada ) +
136+ geom_sf(data = cities , aes(size = pop ), color = " red" , alpha = 0.3 )
137+ ggplotly(p )
138+ })
0 commit comments