adjust_alpha_scale: Adjust Alpha Scale for Data Visualization

View source: R/AdjustAlphaScale.R

adjust_alpha_scaleR Documentation

Adjust Alpha Scale for Data Visualization

Description

This function dynamically adjusts the transparency scale for visualizations, especially useful when the range of data values varies significantly across different sources. It modifies the transparency scale based on the range of values present in the data, ensuring that the visualization accurately reflects variations within the data.

Usage

adjust_alpha_scale(data, name, range = c(0.2, 0.8))

Arguments

data

A data frame containing the values for which the alpha scale is to be adjusted.

name

Character string that will be used as the title of the legend in the plot.

range

Numeric vector of length 2 specifying the range of alpha values, defaults to c(0.2, 0.8).

Value

A ggplot2 alpha scale adjustment layer.

Examples

# Assuming 'data' is a DataFrame with a 'value' column
plot_data <- data.frame(value = c(10, 20, 30, 40, 50))
ggplot2::ggplot(plot_data, ggplot2::aes(x = 1:nrow(plot_data), y = value)) +
  ggplot2::geom_point(ggplot2::aes(alpha = value)) +
  adjust_alpha_scale(plot_data, "Transparency Scale")


TransProR documentation built on April 4, 2025, 3:16 a.m.