Create Plot Options for Margot Plot
Source:R/margot_plot_create_options.R
margot_plot_create_options.Rd
This function creates a list of options for use with the `margot_plot` function. It allows for easy customization of plot settings while maintaining a set of default values.
Usage
margot_plot_create_options(
subtitle,
base_defaults = NULL,
title = NULL,
filename_prefix = NULL,
label_mapping = NULL,
save_output = FALSE,
use_timestamp = FALSE,
base_filename = "margot_plot_output",
save_path = NULL,
...
)
Arguments
- subtitle
Character string. The subtitle for the plot.
- base_defaults
List. The base default options to use. If not provided, uses a pre-defined set of defaults.
- title
Character string. The title for the plot. If NULL, uses the title from base_defaults.
- filename_prefix
Character string. Prefix for the filename. If NULL, uses a default prefix.
- label_mapping
Named list. Mapping of original outcome labels to new labels.
- save_output
Logical. Whether to save the complete output. Default is FALSE.
- use_timestamp
Logical. Whether to add a timestamp to the output filename. Default is FALSE.
- base_filename
Character string. Base name for the output file. Default is "margot_plot_output".
- save_path
Character string. Path where the output should be saved. Default is NULL.
- ...
Additional named arguments to override or add to the default options.
Details
The function allows customization of various plot parameters, including color schemes, text sizes, label transformations, and output saving options. The `label_mapping` parameter enables custom renaming of specific outcomes without affecting the default transformations for other labels.
Examples
if (FALSE) { # \dontrun{
# Basic usage
health_options <- margot_plot_create_options("Health Outcomes")
# Custom title, filename prefix, and output saving
education_options <- margot_plot_create_options(
"Education Outcomes",
title = "Custom Title",
filename_prefix = "edu_outcomes",
save_output = TRUE,
use_timestamp = TRUE,
base_filename = "education_analysis",
save_path = "path/to/save"
)
# Using label_mapping for custom outcome labels
trust_science_options <- margot_plot_create_options(
subtitle = "Trust in Science Outcomes",
title = "Science Trust Analysis",
filename_prefix = "science_trust",
label_mapping = list(
"t2_trust_science_our_society_places_too_much_emphasis_reversed_z" = "Science Overemphasis"
),
colors = c(
"positive" = "#4CAF50",
"not reliable" = "#FFC107",
"negative" = "#F44336"
),
base_size = 16,
point_size = 4,
save_output = TRUE
)
# Use the created options in margot_plot
result <- margot_plot(your_data, options = trust_science_options)
} # }