wrap_string_to_plot: Wrap a Character String to a Plotting Area.

View source: R/plots.R

wrap_string_to_plotR Documentation

Wrap a Character String to a Plotting Area.

Description

'wrap_string_to_plot()' calculates the optimal 'cex' and 'width' for a character string to be added as a plot title. It works once a plot device has been called.

Usage

wrap_string_to_plot(
  string,
  max_cex = 1,
  min_cex = 0.5,
  string_font = 2,
  max_height = graphics::par("din")[2] - graphics::par("pin")[2] -
    graphics::par("omi")[1] - graphics::par("mai")[1] - 0.2,
  init_strwrap_width = 50,
  min_width = 0.9 * graphics::par("din")[1],
  max_width = 0.9 * graphics::par("din")[1],
  whole = TRUE
)

Arguments

string

A character vector with the text to be plotted

max_cex

A real number, giving the maximum *cex* (**c**haracter **ex**pansion) for the string to be plotted

min_cex

minimum character expansion to be used on the title

string_font

font type to be used on the title

max_height

A real number, giving the maximum height to be covered by the text

init_strwrap_width

A real number indicating the minimum number of characters to be plotted by line

min_width

A real number, giving the minimum width to be occupied by the string

max_width

A real number, giving the maximum width to be occupied by the string

whole

Boolean, indicating if the whole string should be plotted even if it surpasses the limits established in previous arguments

Details

Idea to use [strwrap()] from https://stackoverflow.com/questions/7367138/text-wrap-for-plot-titles


phylotastic/datelifeplot documentation built on July 14, 2022, 12:35 p.m.