README.md

The exhibitionist package provides functions for showing and annotating sequences of characters or numbers.

What’s in the box

Installation

You can install from GitHub with:

# install.packages("devtools")
devtools::install_github("coolbutuseless/exhibitionist")

show_bit() for displaying integers and doubles in the terminal

show_bits(12345.67)
#> 0 10000001100 (13) 1000000111001101010111000010100011110101110000101001 : 12345.67
show_bits(12345L)
#> 00000000000000000011000000111001

Built in annotation for ‘doubles’

plot_double(1.2345e87)

plot_compact_double(1.2345e87, base_size = 5, legend.text.multiplier = 2)

Some miscellaneous examples

Annotating the word ‘exhibitionist’ for the header of this page

The header of this page was made with this package.

The two key data.frames are:

Styling columns:

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Create the characters data.frame
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
chars_df <- tibble(
  char        = strsplit("Exhibitionist", '')[[1]],
  x           = seq_along(char),
  text_colour = 'black'
)

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Set the word 'bit' to be BLUE text
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
chars_df$text_colour[5:7] <- 'blue'

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# How should the individual characters be labelled
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
annotation_df <- readr::read_csv(
"start, end,  segment,  text, text_size, label               , segment_colour, segment_size
     1,   4,    TRUE ,  TRUE,         7, A package for       , grey30        , 1
     5,   7,    TRUE ,  TRUE,         7, annotating          , darkgreen     , 2
     8,  13,    TRUE ,  TRUE,         7, bit & char sequences, orange        , 1
")

plot_chars(chars_df, annotation_df) + ylim(-2, 1.5)

Annotating way too much

This is a demonstration of a lot more options you can change to modify appearance.

In general:

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Create the characters data.frame
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
chars_df <- tibble(
  char        = strsplit("Over the top", '')[[1]],
  x           = seq_along(char),
  text_colour = 'black',
  text_size   = 11,
  text_angle  = 0
)

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Style a lot of the characters
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
chars_df <- chars_df %>% 
  mutate(
    text_colour = if_else(x %% 2 == 0, 'red', text_colour),
    text_angle  = if_else(x %% 3 == 0,   45 , text_angle ),
    text_size   = if_else(x %% 6 == 0,   28 , text_size  ),
    tile_fill   = if_else(char == ' ', NA_character_, 'white'),
    tile_colour = if_else(char == ' ', NA_character_, 'black')
  )

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# How should the individual characters be labelled underneath?
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
annotation_df <- readr::read_csv(
"start, end,  segment,  text, text_size, label               , segment_colour, segment_linetype, segment_size, text_family, text_angle, text_hjust
     1,   4,    TRUE ,  TRUE,        10, Over it!!           , darkgreen     , 1               , 1           , serif      , 0         ,  0.5
     6,   8,    TRUE ,  TRUE,         7, Too Much?           , blue          , 2               , 2           ,            , 45        ,  1
    10,  12,    TRUE ,  TRUE,         7, Or not enough??     , orange        , 3               , 4           ,            , 180       ,  0.5
")

plot_chars(chars_df, annotation_df) + 
  ylim(-2, 1.2)



coolbutuseless/exhibitionist documentation built on Nov. 4, 2019, 9:12 a.m.