plot_n: Plot n tiles.

View source: R/plot_fun.R

plot_nR Documentation

Plot n tiles.

Description

plot_n plots a row or column of n tiles on fixed or polar coordinates.

Usage

plot_n(
  n = NA,
  row = TRUE,
  polar = FALSE,
  pal = pal_ds4psy,
  sort = TRUE,
  borders = TRUE,
  border_col = "black",
  border_size = 0,
  lbl_tiles = FALSE,
  lbl_title = FALSE,
  rseed = NA,
  save = FALSE,
  save_path = "images/tiles",
  prefix = "",
  suffix = ""
)

Arguments

n

Basic number of tiles (on either side).

row

Plot as a row? Default: row = TRUE (else plotted as a column).

polar

Plot on polar coordinates? Default: polar = FALSE (i.e., using fixed coordinates).

pal

A color palette (automatically extended to n colors). Default: pal = pal_ds4psy.

sort

Sort tiles? Default: sort = TRUE (i.e., sorted tiles).

borders

Add borders to tiles? Default: borders = TRUE (i.e., use borders).

border_col

Color of borders (if borders = TRUE). Default: border_col = "black".

border_size

Size of borders (if borders = TRUE). Default: border_size = 0 (i.e., invisible).

lbl_tiles

Add numeric labels to tiles? Default: lbl_tiles = FALSE (i.e., no labels).

lbl_title

Add numeric label (of n) to plot? Default: lbl_title = FALSE (i.e., no title).

rseed

Random seed (number). Default: rseed = NA (using random seed).

save

Save plot as png file? Default: save = FALSE.

save_path

Path to save plot (if save = TRUE). Default: save_path = "images/tiles".

prefix

Prefix to plot name (if save = TRUE). Default: prefix = "".

suffix

Suffix to plot name (if save = TRUE). Default: suffix = "".

Details

Note that a polar row makes a tasty pie, whereas a polar column makes a target plot.

See Also

pal_ds4psy for default color palette.

Other plot functions: plot_charmap(), plot_chars(), plot_fn(), plot_fun(), plot_text(), plot_tiles(), theme_clean(), theme_ds4psy(), theme_empty()

Examples

# (1) Basics (as ROW or COL): 
plot_n()  # default plot (random n, row = TRUE, with borders, no labels)
plot_n(row = FALSE)  # default plot (random n, with borders, no labels)

plot_n(n = 4, sort = FALSE)      # random order
plot_n(n = 6, borders = FALSE)   # no borders
plot_n(n = 8, lbl_tiles = TRUE,  # with tile + 
       lbl_title = TRUE)         # title labels 

# Set colors: 
plot_n(n = 5, row = TRUE, lbl_tiles = TRUE, lbl_title = TRUE,
       pal = c("orange", "white", "firebrick"),
       border_col = "white", border_size = 2)
  
# Fixed rseed:
plot_n(n = 4, sort = FALSE, borders = FALSE, 
       lbl_tiles = TRUE, lbl_title = TRUE, rseed = 101)

# (2) polar plot (as PIE or TARGET):    
plot_n(polar = TRUE)  # PIE plot (with borders, no labels)
plot_n(polar = TRUE, row = FALSE)  # TARGET plot (with borders, no labels)

plot_n(n = 4, polar = TRUE, sort = FALSE)      # PIE in random order
plot_n(n = 5, polar = TRUE, row = FALSE, borders = FALSE)   # TARGET no borders
plot_n(n = 5, polar = TRUE, lbl_tiles = TRUE)  # PIE with tile labels 
plot_n(n = 5, polar = TRUE, row = FALSE, lbl_title = TRUE)  # TARGET with title label 

# plot_n(n = 4, row = TRUE, sort = FALSE, borders = TRUE,  
#        border_col = "white", border_size = 2, 
#        polar = TRUE, rseed = 132)
# plot_n(n = 4, row = FALSE, sort = FALSE, borders = TRUE,  
#        border_col = "white", border_size = 2, 
#        polar = TRUE, rseed = 134)
 

ds4psy documentation built on Sept. 15, 2023, 9:08 a.m.