Skip to content

Commit 66462be

Browse files
authored
Export translate_shape_string() (#5270)
* Export `translate_shape_string()` * Add NEWS bullet
1 parent c468bb3 commit 66462be

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,7 @@ export(theme_test)
688688
export(theme_update)
689689
export(theme_void)
690690
export(transform_position)
691+
export(translate_shape_string)
691692
export(unit)
692693
export(update_geom_defaults)
693694
export(update_labels)

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# ggplot2 (development version)
22

3+
* The `translate_shape_string()` internal function is now exported for use in
4+
extensions of point layers (@teunbrand, #5191).
5+
* Fixed bug in `coord_sf()` where graticule lines didn't obey
6+
`panel.grid.major`'s linewidth setting (@teunbrand, #5179)
37
* Fixed bug in `annotation_logticks()` when no suitable tick positions could
48
be found (@teunbrand, #5248).
59
* To improve `width` calculation in bar plots with empty factor levels,

R/geom-point.R

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,23 @@ GeomPoint <- ggproto("GeomPoint", Geom,
143143
draw_key = draw_key_point
144144
)
145145

146+
#' Translating shape strings
147+
#'
148+
#' `translate_shape_string()` is a helper function for translating point shapes
149+
#' given as a character vector into integers that are interpreted by the
150+
#' grid system.
151+
#'
152+
#' @param shape_string A character vector giving point shapes.
153+
#'
154+
#' @return An integer vector with translated shapes.
155+
#' @export
156+
#' @keywords internal
157+
#'
158+
#' @examples
159+
#' translate_shape_string(c("circle", "square", "triangle"))
160+
#'
161+
#' # Strings with 1 or less characters are interpreted as symbols
162+
#' translate_shape_string(c("a", "b", "?"))
146163
translate_shape_string <- function(shape_string) {
147164
# strings of length 0 or 1 are interpreted as symbols by grid
148165
if (nchar(shape_string[1]) <= 1) {

man/translate_shape_string.Rd

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)