getPositionAndMargins: Get margins and positions of specific elements for a clinical...

View source: R/plots-utility-dimensions.R

getPositionAndMarginsR Documentation

Get margins and positions of specific elements for a clinical data plot

Description

The elements are positioned as following:

  • on top of the plot

    1. title

    2. subtitle

    3. legend, if positioned on top of the plot

    4. facet title

  • at the bottom of the plot

    1. label for the x-axis

    2. legend, if positioned on the bottom of the plot

    3. caption

Margins are computed based on the presence of these elements.
Only one line is counted for the legend, as plotly will extend the margin if necessary for the legend (for bottom legend).

Usage

getPositionAndMargins(
  title = NULL,
  subtitle = NULL,
  xLab = NULL,
  caption = NULL,
  facet = FALSE,
  includeLegend = TRUE,
  legendPosition = "right"
)

Arguments

title

String with title for the plot.

subtitle

String with subtitle.
The subtitle is included at the top left of the plot, below the title.

xLab

String with label for xVar.

caption

String with caption.
The caption is included at the bottom right of the plot. Please note that this might overlap with vertical or rotated x-axis labels.

facet

Logical, if TRUE the plot contains facets.

includeLegend

Logical, if TRUE (by default) a legend is available in the plot.

legendPosition

String with position of the legend, among: 'top'/'left'/'bottom'/'right', 'right' by default.

Value

List with:

  • 'margin': List with bottom ('t') and top ('t') margins in pixels

  • 'position': List with position of the following plot elements:

    • on top of the plot: subtitle and legend (if positioned at the top).
      The position is defined as the distance in pixels from the top of the plotting area to the bottom of the element (yanchor = 'bottom')

    • at the bottom of the plot: caption, xLab and legend (if positioned at the bottom).
      The position is defined as the distance in pixels from the bottom of the plotting area to the top of the element (yanchor = 'top')
      Especially, the legend should be positioned with anchor 'top' such as the margins are automatically expanded if the legend contains multiple rows.

Author(s)

Laure Cougnaud


clinDataReview documentation built on March 7, 2023, 5:13 p.m.