Skip to contents

This function estimates the height of a figure for a horizontal bar chart based on several parameters including the number of dependent and independent variables, number of categories, maximum characters in the labels, and legend properties.

Usage

fig_height_h_barchart(
  n_y,
  n_cats_y,
  max_chars_y,
  n_x = NULL,
  n_cats_x = NULL,
  max_chars_x = NULL,
  freq = FALSE,
  x_axis_label_width = 20,
  strip_angle = 0,
  main_font_size = 7,
  legend_location = c("plot", "panel"),
  n_legend_lines = 2,
  legend_key_chars_equivalence = 5,
  max_chars_per_figure_width = 100,
  multiplier_per_horizontal_line = NULL,
  multiplier_per_vertical_letter = 1,
  multiplier_per_facet = 1,
  multiplier_per_legend_line = 1,
  fixed_constant = 0,
  figure_width_in_cm = 14,
  margin_in_cm = 0,
  max = 8,
  min = 1
)

Arguments

n_y

Integer. Number of dependent variables.

n_cats_y

Integer. Number of categories across the dependent variables.

max_chars_y

Integer. Maximum number of characters across the dependent variables.

n_x

Integer. Number of independent variables.

n_cats_x

Integer. Number of categories across the independent variables.

max_chars_x

Integer. Maximum number of characters across the independent variables.

freq

Logical. If TRUE, frequency plot with categories next to each other. If FALSE (default), proportion plot with stacked categories.

x_axis_label_width

Numeric. Width allocated for x-axis labels.

strip_angle

Integer. Angle of the strip text.

main_font_size

Numeric. Font size for the main text.

legend_location

Character. Location of the legend ("panel" or "plot").

n_legend_lines

Integer. Number of lines in the legend.

legend_key_chars_equivalence

Integer. Approximate number of characters the legend key equals.

max_chars_per_figure_width

Integer. Maximum number of characters per figure width.

multiplier_per_horizontal_line

Numeric. Multiplier per horizontal line.

multiplier_per_vertical_letter

Numeric. Multiplier per vertical letter.

multiplier_per_facet

Numeric. Multiplier per facet.

multiplier_per_legend_line

Numeric. Multiplier per legend line.

fixed_constant

Numeric. Fixed constant to be added to the height.

figure_width_in_cm

Numeric. Width of the figure in centimeters.

margin_in_cm

Numeric. Margin in centimeters.

max

Numeric. Maximum height.

min

Numeric. Minimum height.

Value

Numeric value representing the estimated height of the figure.

Examples

fig_height_h_barchart(n_y = 5,
                      n_cats_y = 3,
                      max_chars_y = 10,
                      n_x = 2,
                      n_cats_x = 4,
                      max_chars_x = 12,
                      freq = FALSE,
                      x_axis_label_width = 20,
                      strip_angle = 0,
                      main_font_size = 8,
                      legend_location = "panel",
                      n_legend_lines = 2,
                      legend_key_chars_equivalence = 5,
                      max_chars_per_figure_width = 100,
                      multiplier_per_horizontal_line = NULL,
                      multiplier_per_vertical_letter = .15,
                      multiplier_per_facet = .95,
                      multiplier_per_legend_line = 1.5,
                      fixed_constant = 0,
                      figure_width_in_cm = 16,
                      margin_in_cm = 0,
                      max = 8,
                      min = 1)
#> [1] 5.1