Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace grey by gray #1141

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 02-spatial-data.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -821,14 +821,14 @@ library(tmap)
tm1 = tm_shape(india_buffer_with_s2) +
tm_fill(fill = hcl.colors(4, palette = "purple green")[2], lwd = 0.01) +
tm_shape(india) +
tm_fill(fill = "grey95") +
tm_fill(fill = "gray95") +
tm_title("st_buffer() with dist = 1") +
tm_title("s2 switched on (default)", position = tm_pos_in("right", "bottom"), size = 1)

tm2 = tm_shape(india_buffer_without_s2) +
tm_fill(fill = hcl.colors(4, palette = "purple green")[3], lwd = 0.01) +
tm_shape(india) +
tm_fill(fill = "grey95") +
tm_fill(fill = "gray95") +
tm_title(" ") +
tm_title("s2 switched off", position = tm_pos_in("right", "bottom"), size = 1)

Expand Down
2 changes: 1 addition & 1 deletion 04-spatial-operations.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ tm_shape(grid_sf) +
tm_fill(fill = c("queens", "rooks"),
fill.scale = tm_scale(values = c("white", "black"))) +
tm_shape(grid_sf) +
tm_borders(col = "grey", lwd = 2) +
tm_borders(col = "gray", lwd = 2) +
tm_layout(frame = FALSE, legend.show = FALSE,
panel.labels = c("queen", "rook"))
```
Expand Down
4 changes: 2 additions & 2 deletions 10-gis.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,11 @@ aggzone_wgs = st_transform(aggregating_zones, "EPSG:4326")
#| results: hide
library(tmap)
tm_shape(incongr_wgs) +
tm_polygons(col = "grey5") +
tm_polygons(col = "gray5") +
tm_shape(aggzone_wgs) +
tm_borders(col_alpha = 0.5, col = "red") +
tm_add_legend(type = "lines", labels = c("incongr_wgs", "aggzone_wgs"),
col = c("grey5", "red"), lwd = 3, position = tm_pos_in("right", "top")) +
col = c("gray5", "red"), lwd = 3, position = tm_pos_in("right", "top")) +
tm_scalebar(position = c("left", "bottom"), breaks = c(0, 0.5, 1)) +
tm_layout(frame = FALSE, legend.text.size = 1,
inner.margins = c(0.02, 0.02, 0.03, 0.02))
Expand Down
6 changes: 3 additions & 3 deletions _02-ex.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ text(world_coords, world$iso_a2)
# Alternative answer:
nigeria = world[world$name_long == "Nigeria", ]
africa = world[world$continent == "Africa", ]
plot(st_geometry(nigeria), col = "white", lwd = 3, main = "Nigeria in context", border = "lightgrey", expandBB = c(0.5, 0.2, 0.5, 0.2))
plot(st_geometry(world), lty = 3, add = TRUE, border = "grey")
plot(st_geometry(nigeria), col = "yellow", add = TRUE, border = "darkgrey")
plot(st_geometry(nigeria), col = "white", lwd = 3, main = "Nigeria in context", border = "lightgray", expandBB = c(0.5, 0.2, 0.5, 0.2))
plot(st_geometry(world), lty = 3, add = TRUE, border = "gray")
plot(st_geometry(nigeria), col = "yellow", add = TRUE, border = "darkgray")
a = africa[grepl("Niger", africa$name_long), ]
ncentre = st_centroid(a)
ncentre_num = st_coordinates(ncentre)
Expand Down
8 changes: 4 additions & 4 deletions _04-ex.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ The starting point of this exercise is to create an object representing Colorado
```{r 04-ex-4-1}
colorado = us_states[us_states$NAME == "Colorado", ]
plot(us_states$geometry)
plot(colorado$geometry, col = "grey", add = TRUE)
plot(colorado$geometry, col = "gray", add = TRUE)
```

```{r 04-ex-4-2}
intersects_with_colorado = us_states[colorado, , op = st_intersects]
plot(us_states$geometry, main = "States that intersect with Colorado")
plot(intersects_with_colorado$geometry, col = "grey", add = TRUE)
plot(intersects_with_colorado$geometry, col = "gray", add = TRUE)
```

```{r 04-ex-4-3}
Expand All @@ -103,7 +103,7 @@ us_states |>
```{r 04-ex-4-4}
touches_colorado = us_states[colorado, , op = st_touches]
plot(us_states$geometry, main = "States that touch Colorado")
plot(touches_colorado$geometry, col = "grey", add = TRUE)
plot(touches_colorado$geometry, col = "gray", add = TRUE)
```


Expand All @@ -116,7 +116,7 @@ washington_to_cali = us_states |>
states_crossed = us_states[washington_to_cali, , op = st_crosses]
states_crossed$NAME
plot(us_states$geometry, main = "States crossed by a straight line\n from the District of Columbia to central California")
plot(states_crossed$geometry, col = "grey", add = TRUE)
plot(states_crossed$geometry, col = "gray", add = TRUE)
plot(washington_to_cali, add = TRUE)
```

Expand Down
4 changes: 2 additions & 2 deletions _09-ex.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ tmap_animation(tma1, filename = "tma2.gif", width = 1000, height = 1000)
browseURL("tma1.gif")

tma2 = tm_shape(africa) +
tm_polygons(fill = "lightgrey") +
tm_polygons(fill = "lightgray") +
tm_shape(ea) +
tm_polygons(fill = "darkgrey") +
tm_polygons(fill = "darkgray") +
tm_shape(ea) +
tm_polygons(fill = "HDI") +
tm_facets(by = "name", nrow = 1, ncol = 1)
Expand Down
4 changes: 2 additions & 2 deletions _404.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ null_island = st_point(c(0, 0))
null_island = st_sfc(null_island, crs = 4326)
null_island = st_sf(name = "Null Island", geom = null_island)
tm_shape(null_island) +
tm_graticules(labels.col = "grey40") +
tm_graticules(labels.col = "gray40") +
tm_text("name", size = 5, fontface = "italic") +
tm_layout(bg.color = "lightblue") +
tm_title("You are here:", color = "grey40")
tm_title("You are here:", color = "gray40")
```

2 changes: 1 addition & 1 deletion code/02-contpop.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ par(mar = c(0, 0, 0, 0))
plot(world_proj["continent"], reset = FALSE, main = "", key.pos = NULL)
g = st_graticule()
g = st_transform(g, crs = "+proj=eck4")
plot(g$geometry, add = TRUE, col = "lightgrey")
plot(g$geometry, add = TRUE, col = "lightgray")
cex = sqrt(world$pop) / 10000
plot(st_geometry(world_cents), add = TRUE, cex = cex, lwd = 2, graticule = TRUE)
6 changes: 3 additions & 3 deletions code/02-vectorplots.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ london_orign = rbind(london_osgb, origin_osgb)
png("images/vector_lonlat.png")
globe::globeearth(eye = c(0, 0))
gratmat = st_coordinates(st_graticule())[, 1:2]
globe::globelines(loc = gratmat, col = "grey", lty = 3)
globe::globelines(loc = gratmat, col = "gray", lty = 3)
globe::globelines(loc = matrix(c(-90, 90, 0, 0), ncol = 2))
globe::globelines(loc = matrix(c(0, 0, -90, 90), ncol = 2))
globe::globepoints(loc = c(-0.1, 51.5), pch = 4, cex = 2, lwd = 3, col = "red")
Expand All @@ -28,6 +28,6 @@ uk = rnaturalearth::ne_countries(scale = 50) %>%
plot(uk$geometry)
plot(london_orign$geometry[1], add = TRUE, pch = 4, cex = 2, lwd = 3, col = "red")
plot(london_orign$geometry[2], add = TRUE, pch = 1, cex = 2, lwd = 3, col = "blue")
abline(h = seq(0, 9e5, length.out = 10), col = "grey", lty = 3)
abline(v = seq(0, 9e5, length.out = 10), col = "grey", lty = 3)
abline(h = seq(0, 9e5, length.out = 10), col = "gray", lty = 3)
abline(v = seq(0, 9e5, length.out = 10), col = "gray", lty = 3)
dev.off()
28 changes: 14 additions & 14 deletions code/05-venn-clip.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,33 @@ if (!exists("b")) {
}

old_par = par(mfrow = c(2, 3), mai = c(0.1, 0.1, 0.1, 0.1))
plot(b, border = "grey")
plot(x, add = TRUE, col = "lightgrey", border = "grey")
plot(b, border = "gray")
plot(x, add = TRUE, col = "lightgray", border = "gray")
text(cex = 1.8, x = 0.5, y = 1, "x")
plot(b, add = TRUE, border = "grey")
plot(b, add = TRUE, border = "gray")
x_not_y = st_difference(x, y)
plot(b, border = "grey")
plot(x_not_y, col = "lightgrey", add = TRUE, border = "grey")
plot(b, border = "gray")
plot(x_not_y, col = "lightgray", add = TRUE, border = "gray")
text(cex = 1.8, x = 0.5, y = 1, "st_difference(x, y)")

y_not_x = st_difference(y, x)
plot(b, border = "grey")
plot(y_not_x, col = "lightgrey", add = TRUE, border = "grey")
plot(b, border = "gray")
plot(y_not_x, col = "lightgray", add = TRUE, border = "gray")
text(cex = 1.8, x = 0.5, y = 1, "st_difference(y, x)")
x_or_y = st_union(x, y)
plot(x_or_y, col = "lightgrey", border = "grey")
plot(x_or_y, col = "lightgray", border = "gray")
text(cex = 1.8, x = 0.5, y = 1, "st_union(x, y)")
x_and_y = st_intersection(x, y)
plot(b, border = "grey")
plot(x_and_y, col = "lightgrey", add = TRUE, border = "grey")
plot(b, border = "gray")
plot(x_and_y, col = "lightgray", add = TRUE, border = "gray")
text(cex = 1.8, x = 0.5, y = 1, "st_intersection(x, y)")
# x_xor_y = st_difference(x_xor_y, x_and_y) # failing
x_xor_y = st_sym_difference(x, y)
plot(x_xor_y, col = "lightgrey", border = "grey")
plot(x_xor_y, col = "lightgray", border = "gray")
text(cex = 1.8, x = 0.5, y = 1, "st_sym_difference(x, y)")
# plot.new()
# plot(b, border = "grey")
# plot(y, col = "lightgrey", add = TRUE, border = "grey")
# plot(b, add = TRUE, border = "grey")
# plot(b, border = "gray")
# plot(y, col = "lightgray", add = TRUE, border = "gray")
# plot(b, add = TRUE, border = "gray")
# text(cex = 1.2, x = 0.5, y = 1, "y")
par(old_par)
2 changes: 1 addition & 1 deletion code/13-cycleways.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ bristol_stations_top = bristol_stations[desire_rail, , op = st_is_within_distanc
m_leaflet = tm_shape(bristol_ttwa) +
tm_borders(col = "darkblue") +
tm_shape(bristol_ways) +
tm_lines(col = "highway", lwd = 3, palette = c("lightgreen", "grey", "pink")) +
tm_lines(col = "highway", lwd = 3, palette = c("lightgreen", "gray", "pink")) +
tm_scalebar() +
tm_shape(route_cycleway) +
tm_lines(col = "blue", lwd = "all", scale = 20, alpha = 0.6) +
Expand Down
4 changes: 2 additions & 2 deletions code/chapters/02-spatial-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -419,14 +419,14 @@ library(tmap)
tm1 = tm_shape(india_buffer_with_s2) +
tm_fill(col = hcl.colors(4, palette = "purple green")[3]) +
tm_shape(india) +
tm_fill(col = "grey95") +
tm_fill(col = "gray95") +
tm_layout(main.title = "st_buffer() with dist = 1",
title = "s2 switched on (default)")

tm2 = tm_shape(india_buffer_without_s2) +
tm_fill(col = hcl.colors(4, palette = "purple green")[3]) +
tm_shape(india) +
tm_fill(col = "grey95") +
tm_fill(col = "gray95") +
tm_layout(main.title = " ",
title = "s2 switched off")

Expand Down
2 changes: 1 addition & 1 deletion code/chapters/04-spatial-operations.R
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ plot(grid, col = grid_sf$rooks)
tm_shape(grid_sf) +
tm_fill(col = c("queens", "rooks"), palette = c("white", "black")) +
tm_shape(grid_sf) +
tm_borders(col = "grey", lwd = 2) +
tm_borders(col = "gray", lwd = 2) +
tm_layout(frame = FALSE, legend.show = FALSE,
panel.labels = c("queen", "rook"))

Expand Down
12 changes: 6 additions & 6 deletions code/chapters/05-geometry-operations.R
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,16 @@ nz_scale_sf = st_set_geometry(nz, nz_scale)
## ----points, fig.cap="Overlapping circles.", fig.asp=0.4, crop = TRUE-------------------------------
b = st_sfc(st_point(c(0, 1)), st_point(c(1, 1))) # create 2 points
b = st_buffer(b, dist = 1) # convert points to circles
plot(b, border = "grey")
plot(b, border = "gray")
text(x = c(-0.5, 1.5), y = 1, labels = c("x", "y"), cex = 3) # add text


## ----circle-intersection, fig.cap="Overlapping circles with a gray color indicating intersection between them.", fig.asp=0.4, fig.scap="Overlapping circles showing intersection types.", crop = TRUE----
x = b[1]
y = b[2]
x_and_y = st_intersection(x, y)
plot(b, border = "grey")
plot(x_and_y, col = "lightgrey", border = "grey", add = TRUE) # intersecting area
plot(b, border = "gray")
plot(x_and_y, col = "lightgray", border = "gray", add = TRUE) # intersecting area


## ----venn-clip, echo=FALSE, fig.cap="Spatial equivalents of logical operators.", warning=FALSE------
Expand All @@ -194,9 +194,9 @@ box = st_as_sfc(bb)
set.seed(2017)
p = st_sample(x = box, size = 10)
p_xy1 = p[x_and_y]
plot(box, border = "grey", lty = 2)
plot(x, add = TRUE, border = "grey")
plot(y, add = TRUE, border = "grey")
plot(box, border = "gray", lty = 2)
plot(x, add = TRUE, border = "gray")
plot(y, add = TRUE, border = "gray")
plot(p, add = TRUE)
plot(p_xy1, cex = 3, col = "red", add = TRUE)
text(x = c(-0.5, 1.5), y = 1, labels = c("x", "y"), cex = 2)
Expand Down
4 changes: 2 additions & 2 deletions code/chapters/10-gis.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ aggzone_wgs = st_transform(aggregating_zones, "EPSG:4326")
## ----uniondata, echo=FALSE, fig.cap="Illustration of two areal units: incongruent (black lines) and aggregating zones (red borders). "----
library(tmap)
tm_shape(incongr_wgs) +
tm_polygons(border.col = "grey5") +
tm_polygons(border.col = "gray5") +
tm_shape(aggzone_wgs) +
tm_borders(alpha = 0.5, col = "red") +
tm_add_legend(type = "line",
labels = c("incongr_wgs", "aggzone_wgs"),
col = c("grey5", "red"),
col = c("gray5", "red"),
lwd = 3) +
tm_scale_bar(position = c("left", "bottom"),
breaks = c(0, 0.5, 1)) +
Expand Down
6 changes: 3 additions & 3 deletions code/chapters/_02-ex.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ text(world_coords, world$iso_a2)
# Alternative answer:
nigeria = world[world$name_long == "Nigeria", ]
africa = world[world$continent == "Africa", ]
plot(st_geometry(nigeria), col = "white", lwd = 3, main = "Nigeria in context", border = "lightgrey", expandBB = c(0.5, 0.2, 0.5, 0.2))
plot(st_geometry(world), lty = 3, add = TRUE, border = "grey")
plot(st_geometry(nigeria), col = "yellow", add = TRUE, border = "darkgrey")
plot(st_geometry(nigeria), col = "white", lwd = 3, main = "Nigeria in context", border = "lightgray", expandBB = c(0.5, 0.2, 0.5, 0.2))
plot(st_geometry(world), lty = 3, add = TRUE, border = "gray")
plot(st_geometry(nigeria), col = "yellow", add = TRUE, border = "darkgray")
a = africa[grepl("Niger", africa$name_long), ]
ncentre = st_centroid(a)
ncentre_num = st_coordinates(ncentre)
Expand Down
8 changes: 4 additions & 4 deletions code/chapters/_04-ex.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ nz_height_combined |>
## ----04-ex-4-1--------------------------------------------------------------------------------------
colorado = us_states[us_states$NAME == "Colorado", ]
plot(us_states$geometry)
plot(colorado$geometry, col = "grey", add = TRUE)
plot(colorado$geometry, col = "gray", add = TRUE)


## ----04-ex-4-2--------------------------------------------------------------------------------------
intersects_with_colorado = us_states[colorado, , op = st_intersects]
plot(us_states$geometry, main = "States that intersect with Colorado")
plot(intersects_with_colorado$geometry, col = "grey", add = TRUE)
plot(intersects_with_colorado$geometry, col = "gray", add = TRUE)


## ----04-ex-4-3--------------------------------------------------------------------------------------
Expand All @@ -86,7 +86,7 @@ us_states |>
## ----04-ex-4-4--------------------------------------------------------------------------------------
touches_colorado = us_states[colorado, , op = st_touches]
plot(us_states$geometry, main = "States that touch Colorado")
plot(touches_colorado$geometry, col = "grey", add = TRUE)
plot(touches_colorado$geometry, col = "gray", add = TRUE)


## ----04-ex-4-5--------------------------------------------------------------------------------------
Expand All @@ -98,7 +98,7 @@ washington_to_cali = us_states |>
states_crossed = us_states[washington_to_cali, , op = st_crosses]
states_crossed$NAME
plot(us_states$geometry, main = "States crossed by a straight line\n from the District of Columbia to central California")
plot(states_crossed$geometry, col = "grey", add = TRUE)
plot(states_crossed$geometry, col = "gray", add = TRUE)
plot(washington_to_cali, add = TRUE)


Expand Down
4 changes: 2 additions & 2 deletions code/chapters/_404.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ null_island = st_point(c(0, 0))
null_island = st_sfc(null_island, crs = 4326)
null_island = st_sf(name = "Null Island", geom = null_island)
tm_shape(null_island) +
tm_graticules(labels.col = "grey40") +
tm_graticules(labels.col = "gray40") +
tm_text("name", size = 5, fontface = "italic") +
tm_layout(bg.color = "lightblue",
main.title = "You are here:",
main.title.color = "grey40")
main.title.color = "gray40")

2 changes: 1 addition & 1 deletion code/front_cover2.R
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ col_lv4 = alpha(pal[12], alp)
col_lv5 = alpha(pal[15], alp)

col_world = "#073B4C"
col_borders = "grey80"
col_borders = "gray80"
col_back = "#1D201F"

pal_dis = moma.colors("ustwo" , n = 5, type = "discrete")
Expand Down
2 changes: 1 addition & 1 deletion code/hex_sticker.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ sticker(
# y = st_geometry(y) %>%
# st_transform(st_crs("+proj=laea +y_0=0 +lon_0=0 +lat_0=0 +ellps=WGS84 +no_defs"))
# y = y + c(lon_0, 0)
# plot(st_geometry(x), col = "grey")
# plot(st_geometry(x), col = "gray")
# plot(st_geometry(y), add = TRUE, col = "blue")
# }
#
Expand Down
2 changes: 1 addition & 1 deletion code/old-to-future-remove/10-earthquakes.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ print(paste0(nrow(earthquakes), " significant earthquakes happened last month"))

# map ---------------------------------------------------------------------

plot(st_geometry(world), border = "grey")
plot(st_geometry(world), border = "gray")
plot(st_geometry(earthquakes), cex = earthquakes$mag, add = TRUE)
title(paste0(
"Location of significant (mag > 5) Earthquakes in the month to ",
Expand Down
10 changes: 5 additions & 5 deletions code/sf-classes.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ p_linestring_sf = ggplot() +
axis.title = element_blank())

p_polygon_sf = ggplot() +
geom_sf(data = polygon_sf, fill = "grey") +
geom_sf(data = polygon_sf, fill = "gray") +
labs(title = "POLYGON") +
coord_sf(xlim = c(0.6, 1.6), ylim = c(0.4, 1.4)) +
theme(line = element_blank(),
Expand All @@ -92,7 +92,7 @@ p_multilinestring_sf = ggplot() +
axis.title = element_blank())

p_multipolygon_sf = ggplot() +
geom_sf(data = multipolygon_sf, fill = "grey") +
geom_sf(data = multipolygon_sf, fill = "gray") +
labs(title = "MULTIPOLYGON") +
coord_sf(xlim = c(0.6, 1.6), ylim = c(0.4, 1.4)) +
theme(line = element_blank(),
Expand All @@ -102,10 +102,10 @@ p_multipolygon_sf = ggplot() +
p_geometrycollection_sf = ggplot() +
geom_sf(data = point_sf) +
geom_sf(data = linestring_sf) +
geom_sf(data = polygon_sf, fill = "grey") +
geom_sf(data = polygon_sf, fill = "gray") +
geom_sf(data = multipoint_sf) +
geom_sf(data = multilinestring_sf) +
geom_sf(data = multipolygon_sf, fill = "grey") +
geom_sf(data = multipolygon_sf, fill = "gray") +
labs(title = "GEOMETRYCOLLECTION") +
coord_sf(xlim = c(0.6, 1.6), ylim = c(0.4, 1.4)) +
theme(
Expand All @@ -125,7 +125,7 @@ mygb = function(x, y) {
grid.bezier(
x = x,
y = y,
gp = gpar(col = "grey", fill = "grey"),
gp = gpar(col = "gray", fill = "gray"),
arrow = arrow(type = "closed", length = unit(2, "mm"))
)
}
Expand Down
Loading