| Title: | Tinting and Shading Aesthetics for 'ggplot2' |
|---|---|
| Description: | Adds a 'tintshade' aesthetic to 'ggplot2' that varies the lightness of a mapped 'colour' or 'fill' within each hue group, keeping the plotted layer and its legend in sync. Supports both nested designs (each item belongs to one hue) and crossed designs (each lightness level appears across hues). |
| Authors: | William Kumler [aut, cre] |
| Maintainer: | William Kumler <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.2 |
| Built: | 2026-07-23 15:51:29 UTC |
| Source: | https://github.com/cran/ggtintshade |
Drop-in tintshade variants of common ggplot2 geoms. Map colour or fill
to a hue and tintshade to a within-hue lightness; whichever of
colour/fill carries the hue is tinted automatically (or both, if both are
mapped). The plotted layer and its legend stay in sync.
geom_point_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_jitter_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "jitter", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_line_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_path_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_step_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_area_tintshade( mapping = NULL, data = NULL, stat = "align", position = "stack", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_ribbon_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_bar_tintshade( mapping = NULL, data = NULL, stat = "count", position = "stack", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_col_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "stack", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_histogram_tintshade( mapping = NULL, data = NULL, stat = "bin", position = "stack", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_boxplot_tintshade( mapping = NULL, data = NULL, stat = "boxplot", position = "dodge2", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_violin_tintshade( mapping = NULL, data = NULL, stat = "ydensity", position = "dodge", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_tile_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_raster_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_rect_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_polygon_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_segment_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_text_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_label_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_crossbar_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_errorbar_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_linerange_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_pointrange_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_point_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_jitter_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "jitter", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_line_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_path_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_step_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_area_tintshade( mapping = NULL, data = NULL, stat = "align", position = "stack", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_ribbon_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_bar_tintshade( mapping = NULL, data = NULL, stat = "count", position = "stack", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_col_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "stack", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_histogram_tintshade( mapping = NULL, data = NULL, stat = "bin", position = "stack", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_boxplot_tintshade( mapping = NULL, data = NULL, stat = "boxplot", position = "dodge2", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_violin_tintshade( mapping = NULL, data = NULL, stat = "ydensity", position = "dodge", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_tile_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_raster_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_rect_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_polygon_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_segment_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_text_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_label_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_crossbar_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_errorbar_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_linerange_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_pointrange_tintshade( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping, data, stat, position, na.rm, show.legend, inherit.aes, ...
|
Standard
|
A ggplot2 layer.
scale_tintshade_discrete(), guide_tintshade()
library(ggplot2) df <- data.frame( g = rep(c("a", "b", "c"), each = 3), item = rep(c("lo", "mid", "hi"), 3), x = rep(1:3, each = 3), y = runif(9) ) ggplot(df, aes(x, y, colour = g, tintshade = item)) + geom_point_tintshade(size = 4) ggplot(diamonds) + geom_bar_tintshade(aes(x=cut, fill = cut, tintshade = clarity), color="black") mpgsub <- head(mpg, 60) mpgsub$model <- factor(mpgsub$model, levels=unique(mpgsub$model)) ggplot(mpgsub, aes(displ, hwy, colour = manufacturer, tintshade = model)) + geom_point_tintshade(size = 3) ggplot(penguins[!is.na(penguins$bill_len),]) + geom_point_tintshade(aes(x=bill_len, y=bill_dep, fill=species, tintshade=sex), pch=21, color="black", size=3)library(ggplot2) df <- data.frame( g = rep(c("a", "b", "c"), each = 3), item = rep(c("lo", "mid", "hi"), 3), x = rep(1:3, each = 3), y = runif(9) ) ggplot(df, aes(x, y, colour = g, tintshade = item)) + geom_point_tintshade(size = 4) ggplot(diamonds) + geom_bar_tintshade(aes(x=cut, fill = cut, tintshade = clarity), color="black") mpgsub <- head(mpg, 60) mpgsub$model <- factor(mpgsub$model, levels=unique(mpgsub$model)) ggplot(mpgsub, aes(displ, hwy, colour = manufacturer, tintshade = model)) + geom_point_tintshade(size = 3) ggplot(penguins[!is.na(penguins$bill_len),]) + geom_point_tintshade(aes(x=bill_len, y=bill_dep, fill=species, tintshade=sex), pch=21, color="black", size=3)
A ggplot2::guide_legend() whose keys are recoloured to match the tinted
layer. The tintshade scale uses this guide by default.
guide_tintshade( title = ggplot2::waiver(), type = c("auto", "unique", "crossed"), theme = NULL, position = NULL, direction = NULL, override.aes = list(), nrow = NULL, ncol = NULL, reverse = FALSE, order = 0, ... )guide_tintshade( title = ggplot2::waiver(), type = c("auto", "unique", "crossed"), theme = NULL, position = NULL, direction = NULL, override.aes = list(), nrow = NULL, ncol = NULL, reverse = FALSE, order = 0, ... )
title |
Legend title. Defaults to the mapped variable name. |
type |
How to colour the legend keys:
|
theme |
A |
position |
A character string indicating where the legend should be placed relative to the plot panels. One of "top", "right", "bottom", "left", or "inside". |
direction |
A character string indicating the direction of the guide. One of "horizontal" or "vertical". |
override.aes |
A list specifying aesthetic parameters of legend key. See details and examples. |
nrow, ncol
|
The desired number of rows and column of legends respectively. |
reverse |
logical. If |
order |
positive integer less than 99 that specifies the order of this guide among multiple guides. This controls the order in which multiple guides are displayed, not the contents of the guide itself. If 0 (default), the order is determined by a secret algorithm. |
... |
Additional arguments passed on to |
A guide object.
library(ggplot2) df <- expand.grid(hue = c("good", "bad"), level = c("lo", "hi")) df$y <- 1 ggplot(df, aes(hue, y, fill = hue, tintshade = level)) + geom_col_tintshade(position = "dodge") + guides(tintshade = guide_tintshade(type = "crossed"))library(ggplot2) df <- expand.grid(hue = c("good", "bad"), level = c("lo", "hi")) df$y <- 1 ggplot(df, aes(hue, y, fill = hue, tintshade = level)) + geom_col_tintshade(position = "dodge") + guides(tintshade = guide_tintshade(type = "crossed"))
Map a variable to a lightness tint. The mapped value runs from 0 (black)
through 0.5 (the base hue) to 1 (white); the geom rescales these within
each hue group so the ramp restarts per group.
scale_tintshade_discrete( ..., range = c(0.2, 0.8), aesthetics = "tintshade", guide = guide_tintshade() ) scale_tintshade_continuous( ..., range = c(0.2, 0.8), aesthetics = "tintshade", guide = guide_tintshade() )scale_tintshade_discrete( ..., range = c(0.2, 0.8), aesthetics = "tintshade", guide = guide_tintshade() ) scale_tintshade_continuous( ..., range = c(0.2, 0.8), aesthetics = "tintshade", guide = guide_tintshade() )
... |
Passed to |
range |
Numeric length-2 output range within |
aesthetics |
Aesthetic this scale applies to. Defaults to |
guide |
The legend guide. Defaults to |
A ggplot2 scale object.
library(ggplot2) df <- data.frame(x = 1:3, y = 1:3, g = "a", item = c("lo", "mid", "hi")) ggplot(df, aes(x, y, colour = g, tintshade = item)) + geom_point_tintshade(size = 4) + scale_tintshade_discrete(range = c(0.1, 0.9))library(ggplot2) df <- data.frame(x = 1:3, y = 1:3, g = "a", item = c("lo", "mid", "hi")) ggplot(df, aes(x, y, colour = g, tintshade = item)) + geom_point_tintshade(size = 4) + scale_tintshade_discrete(range = c(0.1, 0.9))