From 423b41df91102087e051ddae068375da30552300 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Sat, 6 Apr 2024 23:43:14 +0200 Subject: [PATCH] tweaks --- NEWS.md | 63 ++++++++++++++++++++++++-------- tests/testthat/test-utils-text.R | 13 ++++--- 2 files changed, 56 insertions(+), 20 deletions(-) diff --git a/NEWS.md b/NEWS.md index 5d25ee1..3797e5b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,17 +1,50 @@ # gguidance (development version) -* New guides: - * `guide_axis_custom()` as an axis guide. - -* New compositions: - * `compose_stack()` for stacking guides. - * `compose_ontop()` for overlaying guides. - -* New primitives: - * `primitive_line()` for lines. - * `primitive_ticks()` for tick marks. - * `primitive_labels()` for text labels. - * `primitive_spacer()` for empty space. - * `primitive_title()` for text titles. - * `primitive_bracket()` for labelled brackets. - * `primitive_box()` for rectangles. +Restarted package from scratch, using a different approach. + +## Mechanism + +The crux in gguidance is that you combine a 'key', that contains instructions +on which values are represented, with a 'guide' that controls how these values +are represented. + +## Full guides + +Full guides are guides that you can just drop in the `guides()` function or as +`guide` argument to scales. + +* `guide_axis_custom()` as an axis guide. +* `guide_colourbar_custom()` as a colour/fill guide. +* `guide_coloursteps_custom()` as a colour/fill guide. +* `guide_subtitle()` as a colour/fill guide. + +## Gizmos + +Gizmos are standalone specialised displays. + +* `gizmo_barcap()` for displaying colour gradients with capping options. +* `gizmo_stepcap()` for displaying stepped gradients with capping options. +* `gizmo_density()` for displaying gradient-filled densities. +* `gizmo_histogram()` for displaying gradient-filled histograms. +* `gizmo_grob()` for displaying custom grobs. + +## Compositions + +Compositions offer ways to combine guides. + +* `compose_stack()` for stacking guides. +* `compose_ontop()` for overlaying guides. +* `compose_crux()` for layout out guides in a cross. +* `compose_sandwich()` for flanked guides. + +## Primitives + +Primitives are the most basic elements that guides use. + +* `primitive_line()` for lines. +* `primitive_ticks()` for tick marks. +* `primitive_labels()` for text labels. +* `primitive_spacer()` for empty space. +* `primitive_title()` for text titles. +* `primitive_bracket()` for labelled brackets. +* `primitive_box()` for rectangles. diff --git a/tests/testthat/test-utils-text.R b/tests/testthat/test-utils-text.R index fbbbc42..13c1ec6 100644 --- a/tests/testthat/test-utils-text.R +++ b/tests/testthat/test-utils-text.R @@ -3,11 +3,14 @@ test_that("get_text_dim_cm works", { style <- theme_gray()$text - withr::local_pdf() - - width <- get_text_dim_cm("foobar", style, "width") - height <- get_text_dim_cm("foobar", style, "height") - both <- get_text_dim_cm("foobar", style, "both") + withr::with_pdf( + tempfile(fileext = ".pdf"), + { + width <- get_text_dim_cm("foobar", style, "width") + height <- get_text_dim_cm("foobar", style, "height") + both <- get_text_dim_cm("foobar", style, "both") + } + ) expect_equal(both$width, width) expect_equal(both$height, height)