Configures aesthetic and layout settings for plots generated by gg1d
.
Usage
gg1d_options(
colours_default = c("#66C2A5", "#FC8D62", "#8DA0CB", "#E78AC3", "#A6D854", "#FFD92F",
"#E5C494"),
colours_default_logical = c(`TRUE` = "#648fff", `FALSE` = "#dc267f"),
colours_missing = "grey90",
show_legend_titles = FALSE,
legend_title_position = c("top", "bottom", "left", "right"),
legend_nrow = 4,
legend_ncol = NULL,
legend_title_size = NULL,
legend_text_size = NULL,
legend_key_size = 0.3,
legend_orientation_heatmap = c("horizontal", "vertical"),
show_legend = TRUE,
legend_position = c("right", "left", "bottom", "top"),
na_marker = "!",
na_marker_size = 8,
na_marker_colour = "black",
show_na_marker_categorical = FALSE,
show_na_marker_heatmap = FALSE,
colours_heatmap_low = "purple",
colours_heatmap_high = "seagreen",
transform_heatmap = c("identity", "log10", "log2"),
fontsize_values_heatmap = 3,
show_values_heatmap = FALSE,
colours_values_heatmap = "white",
vertical_spacing = 0,
numeric_plot_type = c("bar", "heatmap"),
y_axis_position = c("left", "right"),
width = 0.9,
relative_height_numeric = 4,
cli_header = "Running gg1d",
interactive_svg_width = NULL,
interactive_svg_height = NULL,
fontsize_barplot_y_numbers = 8,
max_digits_barplot_y_numbers = 3,
fontsize_y_title = 12,
beautify_text = TRUE
)
Arguments
- colours_default
Default colors for categorical variables without a custom palette.
- colours_default_logical
Colors for binary variables: a vector of three colors representing
TRUE
,FALSE
, andNA
respectively (character).- colours_missing
Color for missing (
NA
) values in categorical plots (string).- show_legend_titles
Display titles for legends (flag).
- legend_title_position
Position of the legend title ("top", "bottom", "left", "right").
- legend_nrow
Number of rows in the legend (number).
- legend_ncol
Number of columns in the legend. If set,
legend_nrow
should beNULL
(number).- legend_title_size
Size of the legend title text (number).
- legend_text_size
Size of the text within the legend (number).
- legend_key_size
Size of the legend key symbols (number).
- legend_orientation_heatmap
should legend orientation be "horizontal" or "vertical".
- show_legend
Display the legend on the plot (flag).
- legend_position
Position of the legend ("right", "left", "bottom", "top").
- na_marker
Text used to mark
NA
values in numeric plots (string).- na_marker_size
Size of the text marker for
NA
values (number).- na_marker_colour
Color of the
NA
text marker (string).- show_na_marker_categorical
Show a marker for
NA
values on categorical tiles (flag).- show_na_marker_heatmap
Show a marker for
NA
values on heatmap tiles (flag).- colours_heatmap_low
Color for the lowest value in heatmaps (string).
- colours_heatmap_high
Color for the highest value in heatmaps (string).
- transform_heatmap
Transformation to apply before visualizing heatmap values ("identity", "log10", "log2").
- fontsize_values_heatmap
Font size for heatmap values (number).
- show_values_heatmap
Display numerical values on heatmap tiles (flag).
- colours_values_heatmap
Color for heatmap values (string).
- vertical_spacing
Space between each data row in points (number).
- numeric_plot_type
Type of visualization for numeric data: "bar" or "heatmap".
- y_axis_position
Position of the y-axis ("left" or "right").
- width
controls how much space is present between bars and tiles within each plot. Can be 0-1 where values of 1 makes bars/tiles take up 100% of available space (no gaps between bars).
- relative_height_numeric
how many times taller should numeric plots be relative to categorical tile plots. Only taken into account if numeric_plot_type == "bar" (number)
- cli_header
Text used for h1 header. Included so it can be tweaked by packages that use gg1d, so they can customise how the info messages appear.
- interactive_svg_width, interactive_svg_height
width and height of the interactive graphic region (in inches). Only used when
interactive = TRUE
.- fontsize_barplot_y_numbers
fontsize of the text describing numeric barplot max & min values (number).
- max_digits_barplot_y_numbers
Number of digits to round the numeric barplot max and min values to (number).
- fontsize_y_title
fontsize of the y axis titles (a.k.a the data.frame column names) (number).
- beautify_text
Beautify y-axis text and legend titles by capitalizing words and adding spaces (flag).
Examples
path_gg1d <- system.file("example.csv", package = "gg1d")
df <- read.csv(path_gg1d, header = TRUE, na.strings = "")
# Create Basic Plot
gg1d(df, col_id = "ID", col_sort = "Glasses")
#>
#> ── Running gg1d ────────────────────────────────────────────────────────────────
#>
#> ── Sorting
#> • Sorting X axis by: Glasses
#> • Order type: frequency
#> • Sort order: descending
#> ! Categorical columns must have <= 6 unique values to be visualised. Columns with too many unique values: Date (19)
#>
#> ── Generating Plot
#> ℹ Found 7 plottable columns in data
#> ✔ Plotting column Glasses
#> ✔ Plotting column Age
#> ✔ Plotting column Gender
#> ✔ Plotting column EyeColour
#> ✔ Plotting column Height
#> ✔ Plotting column HairColour
#> ✔ Plotting column WearingHat
#> ! Skipping column WearingHat_tooltip
#> ! Skipping column Date
#> ℹ Stacking plots vertically
#> ℹ Making plot interactive since `interactive = TRUE`
# Configure plot gg1d_options()
gg1d(
lazy_birdwatcher,
col_sort = "Magpies",
palettes = list(
Birdwatcher = c(Robert = "#E69F00", Catherine = "#999999"),
Day = c(Weekday = "#999999", Weekend = "#009E73")
),
options = gg1d_options(
show_legend = TRUE,
fontsize_barplot_y_numbers = 12,
legend_text_size = 16,
legend_key_size = 1,
legend_nrow = 1,
)
)
#>
#> ── Running gg1d ────────────────────────────────────────────────────────────────
#>
#> ── Sorting
#> • Sorting X axis by: Magpies
#> • Order type: frequency
#> • Sort order: descending
#>
#> ── Generating Plot
#> ℹ Found 3 plottable columns in data
#> ✔ Plotting column Magpies
#> ✔ Plotting column Day
#> ✔ Plotting column Birdwatcher
#> ℹ Stacking plots vertically
#> ℹ Making plot interactive since `interactive = TRUE`