get_legend_columns: Gets appropriate number of legend columns based on the plot,...

View source: R/rub_plot.R

get_legend_columnsR Documentation

Gets appropriate number of legend columns based on the plot, font and active graphics device

Description

Gets appropriate number of legend columns based on the plot, font and active graphics device

Usage

get_legend_columns(
  legend_text,
  y_axis_text,
  legend_key_width = plot_width/100,
  legend_key_spacing = plot_width/100,
  plot_width = 6.8,
  base_size = 11,
  base_family = get_font_df()[["family"]],
  systemfonts_suffix = "_systemfonts"
)

Arguments

legend_text

Vector with the legend text

y_axis_text

Vector with the text labels of the y axis

legend_key_width

Legend key width

legend_key_spacing

Legend key spacing

plot_width

Width of the plot in inches, defaults to 6.8

base_size

base font size, defaults to 11

base_family

base font family, defaults to RubFlama

systemfonts_suffix

Suffix attached to the font family name in systemfonts::register_font

Value

Numeric with the number of columns for the legend

References

Examples

get_legend_columns(
  legend_text = c(
    "1 - eigener Verdienst",
    "2 - Mittel der Eltern/Verwandten",
    "3 - Förderung nach BAföG",
    "4 - Stipendium",
    "5 - Sonstiges"
  ),
  y_axis_text = c(
    "Bachelor 2-Fächer (n=251)",
    "FG Bachelor 2-Fächer (n=1.310)"
  )
)

RichardMeyer-Eppler/RUBer documentation built on June 2, 2022, 7:24 p.m.