View source: R/AdjustAlphaScale.R
adjust_alpha_scale | R Documentation |
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.
adjust_alpha_scale(data, name, range = c(0.2, 0.8))
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). |
A ggplot2 alpha scale adjustment layer.
# 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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.