ds4psy (version 0.1.0)

plot_tiles: Plot n-by-n tiles.

Description

plot_tiles plots an area of n-by-n tiles on fixed or polar coordinates.

Usage

plot_tiles(n = NA, pal = pal_ds4psy, sort = TRUE, borders = TRUE,
  border_col = grey(0, 1), border_size = 0.2, lbl_tiles = FALSE,
  lbl_title = FALSE, polar = FALSE, rseed = NA, save = FALSE,
  save_path = "images/tiles", prefix = "", suffix = "")

Arguments

n

Basic number of tiles (on either side).

pal

A color palette (automatically extended to n x 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 = grey(0, 1) (i.e., black).

border_size

Size of borders (if borders = TRUE). Default: border_size = 0.2 (i.e., thin).

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).

polar

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

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 = "".

See Also

pal_ds4psy for default color palette.

Other plot functions: plot_fn, plot_fun, plot_n, theme_ds4psy

Examples

Run this code
# NOT RUN {
# (1) Tile plot:
plot_tiles()  # default plot (random n, with borders, no labels)

plot_tiles(n =  6, sort = FALSE)      # random order
plot_tiles(n =  8, borders = FALSE)   # no borders
plot_tiles(n = 10, lbl_tiles = TRUE)  # with tile labels 
plot_tiles(n = 10, lbl_title = TRUE)  # with title label 

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

# (2) polar plot:  
plot_tiles(polar = TRUE)  # default polar plot (with borders, no labels)

plot_tiles(n =  6, polar = TRUE, sort = FALSE)      # random order
plot_tiles(n =  8, polar = TRUE, borders = FALSE)   # no borders
plot_tiles(n = 10, polar = TRUE, lbl_tiles = TRUE)  # with tile labels 
plot_tiles(n = 10, polar = TRUE, lbl_title = TRUE)  # with title label 

plot_tiles(n = 4, sort = FALSE, borders = TRUE,  
           border_col = "white", border_size = 2, 
           polar = TRUE, rseed = 132)
 
# }

Run the code above in your browser using DataCamp Workspace