plot_triangle: Create a triangle layout ggplot

Description Usage Arguments Details Value Examples

Description

Create a triangle layout ggplot

Usage

1
2
plot_triangle(elements, user_plot, nrow, user_scale = "4cm", gap_size,
  point = c("top", "bottom"))

Arguments

elements

facetting variable elements. Must equal fibonacci_sum(nrow).

user_plot

bare name of a user-supplied plotting function. See details.

nrow

number of rows to generate.

user_scale

overall scaling factor and unit, e.g. "2cm". See details.

gap_size

size of the gap between rows and plots in a row (bare quantity, e.g. 0.2). If missing, this will be taken as 1/4 of user_scale.

point

should the point of the triangle be at the top or the bottom?

Details

The user-supplied function should take a single argument (name is not important, but e.g. letter) which filters the plot to just the relevant letter. It should return the ggplot object. See demo(random_walk).

The scale is a text string, e.g. "2cm" which will be separated into a numeric and text component. The numeric component will scale the plot, while the text component sets the units.

Value

(invisibly) a gtable containing multiple grobs defining the triangle plot.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
## Not run: 
rw <- plot_triangle(letters[1:19], ggshape_random_walk,
                    nrow = 5, user_scale = "3cm", gap_size = 0.2,
                    point = "bottom")
ggsave(rw, filename = "random_triangle_down.png", width = 12, height = 8)
rw <- plot_triangle(letters[1:19], ggshape_random_walk,
                    nrow = 5, user_scale = "3cm", gap_size = 0.2,
                    point = "top")
ggsave(rw, filename = "random_triangle_up.png", width = 12, height = 8)
lang <- plot_triangle(letters[1:19], ggshape_lang_diffs,
                      nrow = 5, user_scale = "3cm", gap_size = 0.2,
                      point = "top")
ggsave(lang, filename = "languages_triangle_up.png", width = 12, height = 8)
eng <- plot_triangle(letters[1:19], ggshape_english_usage,
                     nrow = 5, user_scale = "3cm", gap_size = 0.2,
                     point = "top")
ggsave(eng, filename = "english_triangle_up.png", width = 12, height = 8)
nums <- plot_triangle(1:11, ggshape_rainbow_text,
                      nrow = 4, user_scale = "3cm", gap_size = 0.2,
                      point = "top")
ggsave(nums, filename = "rainbow_nums_triangle_up_11.png", width = 12, height = 8)
nums <- plot_triangle(1:32, ggshape_rainbow_text,
                      nrow = 6, user_scale = "3cm", gap_size = 0.2,
                      point = "top")
ggsave(nums, filename = "rainbow_nums_triangle_up_32.png", width = 12, height = 8)

## End(Not run)

jonocarroll/ggshape documentation built on May 12, 2019, 1:05 p.m.