Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9e427fc

Browse filesBrowse files
committed
add visual test for #1674
1 parent 684c779 commit 9e427fc
Copy full SHA for 9e427fc

File tree

1 file changed

+30
-0
lines changed
Filter options

1 file changed

+30
-0
lines changed

‎tests/testthat/test-ggplot-sf.R

Copy file name to clipboardExpand all lines: tests/testthat/test-ggplot-sf.R
+30Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.