Skip to content

Commit

Permalink
reduced examples (running time)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtennekes committed Jan 27, 2025
1 parent 282d5a8 commit c0756d0
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 328 deletions.
20 changes: 4 additions & 16 deletions R/tm_layers_aux.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,9 @@ tm_tiles = function(server = NA, alpha = NULL, zoom = NULL, max.native.zoom = 17
leaflet::providers


#' Coordinate grid / graticule lines
#'
#' Draw latitude and longitude graticules. It creates a [`tmap-element`] that draws coordinate grid lines. It serves as a
#' layer that can be drawn anywhere between other layers. See [tm_grid()] for
#' drawing horizontal lines.
#'
#' @inheritParams tm_grid
#' @inheritDotParams tm_grid

#' @export
#' @example ./examples/tm_grid.R
#' @rdname tm_grid
tm_graticules = function(x = NA,
y = NA,
n.x = NA,
Expand All @@ -103,13 +96,8 @@ tm_graticules = function(x = NA,

#' Coordinate grid / graticule lines
#'
#' @description
#' * `tm_grid()` draws horizontal and vertical lines according to the
#' coordinate system of the (master) shape object.
#'
#' Creates a [`tmap-element`] that draws coordinate grid lines. It serves as a
#' layer that can be drawn anywhere between other layers. See [tm_graticules()]
#' to draw latitude and longitude graticules.
#' Draws horizontal and vertical lines according to a coordinate reference system (CRS). `tm_grid()` uses the CRS of the (master) shape object, and `tm_graticules()` uses latitude and longitude coordinates (EPSG 4326). It creates a [`tmap-element`] that draws coordinate grid lines. It serves as a
#' layer that can be drawn anywhere between other layers.
#'
#' @param x X coordinates for vertical grid lines. If `NA`, it is specified
#' with a pretty scale and `n.x`.
Expand Down
4 changes: 4 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
* All reverse dependencies have been carefully checked
* We did our utmost best to keep the package as small as possible (e.g. vignettes are only online)

## Resubmission note

* Running time examples decreased

## R CMD check results

0 errors | 0 warnings | 0 note
Expand Down
2 changes: 2 additions & 0 deletions examples/tm_facets.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
\dontrun{
tm_shape(NLD_dist) +
tm_polygons("edu_appl_sci",
fill.scale = tm_scale_intervals(values = "pu_gn", style = "kmeans", n = 7)) +
Expand All @@ -13,3 +14,4 @@ tm_shape(World) +
tm_scale_intervals(values = "pu_gn_div", midpoint = 50)),
fill.legend = tm_legend("")) +
tm_layout(panel.labels = c("Gender Inequality Index (GII)", "World Press Freedom Index"))
}
12 changes: 7 additions & 5 deletions examples/tm_grid.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
\dontrun{
current.mode <- tmap_mode("plot")

tm_shape(NLD_muni) +
tm_shape(NLD_muni) +
tm_polygons() +
tm_grid()

tm_shape(NLD_muni) +
tm_shape(NLD_muni) +
tm_polygons() +
tm_grid(crs = 4326)

tm_shape(NLD_muni) +
tm_shape(NLD_muni) +
tm_polygons() +
tm_grid(crs = 3035, labels.inside.frame = TRUE)

Expand All @@ -29,12 +30,13 @@ tm_shape(NLD_muni) +
data(NLD_muni, World)

tmap_arrange(
qtm(NLD_muni, borders = NULL) + tm_grid(),
qtm(NLD_muni, borders = NULL) + tm_graticules()
qtm(NLD_muni) + tm_grid(),
qtm(NLD_muni) + tm_graticules()
)

qtm(World, shape.crs = "+proj=robin", style = "natural") +
tm_graticules(ticks = FALSE) +
tm_layout(frame=FALSE)

tmap_mode(current.mode)
}
2 changes: 1 addition & 1 deletion examples/tm_logo.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
data(World)

tm_shape(World) +
tm_polygons("HPI", fill.scale = tm_scale_intervals(values = "RdYlGn")) +
tm_polygons("HPI", fill.scale = tm_scale_intervals(values = "brewer.rd_yl_gn")) +
tm_logo(c("https://www.r-project.org/logo/Rlogo.png",
system.file("help", "figures", "logo.png", package = "tmap"))) +
tm_logo("http://blog.kulikulifoods.com/wp-content/uploads/2014/10/logo.png",
Expand Down
2 changes: 2 additions & 0 deletions examples/tm_scale_rgb.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
\dontrun{
require(stars)
file = system.file("tif/L7_ETMs.tif", package = "stars")

Expand All @@ -8,3 +9,4 @@ tm_shape(L7) +

tm_shape(L7) +
tm_rgb(col.scale = tm_scale_rgb(stretch = "histogram"))
}
56 changes: 0 additions & 56 deletions examples/tm_symbols.R
Original file line number Diff line number Diff line change
@@ -1,57 +1,3 @@
metroAfrica = sf::st_intersection(metro, World[World$continent == "Africa", ])
Africa = World[World$continent == "Africa", ]

tm_shape(land) +
tm_raster("cover_cls",
col.scale = tm_scale(
values = cols4all::c4a("brewer.pastel1")[c(3,7,7,2,6,1,2,2)]
),
col.legend = tm_legend_hide()) +
tm_shape(World_rivers) +
tm_lines(lwd = "strokelwd", lwd.scale = tm_scale_asis(values.scale = .3),
col = cols4all::c4a("brewer.pastel1")[2]) +
tm_shape(Africa, is.main = TRUE) +
tm_borders() +
tm_shape(metroAfrica) +
tm_symbols(fill = "red", shape = "pop2020", size = "pop2020",
size.scale = tm_scale_intervals(
breaks = c(1, 2, 5, 10, 15, 20, 25) * 1e6,
values.range = c(0.2,2)
),
size.legend = tm_legend("Population in 2020"),
shape.scale = tm_scale_intervals(
breaks = c(1, 2, 5, 10, 15, 20, 25) * 1e6,
values = c(21, 23, 22, 21, 23, 22)
),
shape.legend = tm_legend_combine("size")) +
tm_labels("name", options = opt_tm_labels(remove_overlap = FALSE))

## to do: replace this example:

\dontrun{
if (require(rnaturalearth)) {

airports <- ne_download(scale=10, type="airports", returnclass = "sf")
airplane <- tmap_icons(system.file("img/airplane.png", package = "tmap"))



current.mode <- tmap_mode("view")

tm_shape(NLD_prov, crs = 4326) +
tm_polygons() +
tm_shape(airports) +
tm_symbols(shape = airplane,
size = "natlscale",
size.legend = tm_legend_hide(),
id = "name"
) +
tm_text(text = "name")

tmap_mode(current.mode)
}
}

########################
## plot symbol shapes
########################
Expand All @@ -68,5 +14,3 @@ tm_shape(x, bbox = tmaptools::bb(x, ext = 1.2)) +
col = "black",
shape.scale = tm_scale_asis()) +
tm_text("id", ymod = -2)

# also supported in view mode :-)
2 changes: 2 additions & 0 deletions man/tm_facets.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

155 changes: 0 additions & 155 deletions man/tm_graticules.Rd

This file was deleted.

Loading

0 comments on commit c0756d0

Please sign in to comment.