Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
teunbrand committed Apr 6, 2024
1 parent 279d06a commit 423b41d
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 20 deletions.
63 changes: 48 additions & 15 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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.
13 changes: 8 additions & 5 deletions tests/testthat/test-utils-text.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 423b41d

Please sign in to comment.