Skip to contents

Rescale the width of a window to open depending on the number of categories of qualitative variable to plot on the x-axis. Can be used for height, considering that it is as if it was a width.

This order can be used:

width()

open()

prior_plot() # not for ggplot2

plot() or any other plotting

post_plot() if prior_plot() has been used # not for ggplot2

close()

Usage

width(
  categ.nb,
  inches.per.categ.nb = 1,
  ini.window.width = 7,
  inch.left.space,
  inch.right.space,
  boundarie.space = 0.5,
  safer_check = TRUE
)

Arguments

categ.nb

Single positive numeric value of number of categories to plot.

inches.per.categ.nb

Single positive numeric value of inches per unit of categ.nb. 2 means 2 inches for each boxplot for instance.

ini.window.width

Single positive numeric value indicating the initial Window width (in inches).

inch.left.space

Single positive numeric value indicating the left horizontal margin of the figure region (in inches).

inch.right.space

Single positive numeric value indicating the right horizontal margin of the figure region (in inches).

boundarie.space

Single positive numeric value indicating the space between the right and left limits of the plotting region and the plot (0.5 means half a category width). It is as if empty categories were added on the right and left of the plot.

safer_check

Single logical value. Perform some "safer" checks (see https://github.com/safer-r)? If TRUE, checkings are performed before main code running: 1) R classical operators (like "<-") not overwritten by another package because of the R scope and 2) required functions and related packages effectively present in local R lybraries. Set to FALSE if this fonction is used inside another "safer" function to avoid pointless multiple checkings.

Value

The new window width in inches.

Author

Gael Millot <gael.millot@pasteur.fr>

Yushi Han <yushi.han2000@gmail.com>

Haiding Wang <wanghaiding442@gmail.com>

Examples

width(categ.nb = 10, inches.per.categ.nb = 0.2, ini.window.width = 7, inch.left.space = 1, inch.right.space = 1, boundarie.space = 0.5)
#> [1] 4