| Title: | Shadow and Glow Geoms for 'ggplot2' |
|---|---|
| Description: | A collection of Geoms for R's 'ggplot2' library. GeomShadowLine, GeomShadowPath, GeomShadowPoint, and GeomShadowStep support drawing a shadow below lines or around points to make busy plots more aesthetically pleasing. GeomGlowLine, GeomGlowPath, GeomGlowPoint, and GeomGlowStep support adding neon glow around lines or points to get a steampunk style. |
| Authors: | Marc Menem [aut, cre], Eli Pousson [ctb] (ORCID: <https://orcid.org/0000-0001-8280-1706>) |
| Maintainer: | Marc Menem <[email protected]> |
| License: | GPL-2 |
| Version: | 0.0.4 |
| Built: | 2026-10-14 08:13:20 UTC |
| Source: | https://github.com/marcmenem/ggshadow |
Plot a glow beneath the connected lines to make it easier to read a chart with several
overlapping observations. geom_glowpath() connects the observations in the order in which they appear
in the data. geom_glowline() connects them in order of the variable on the
x axis. geom_glowstep() creates a stairstep plot, highlighting exactly
when changes occur.
geom_glowpath( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., lineend = "butt", linejoin = "round", linemitre = 10, arrow = NULL, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_glowline( mapping = NULL, data = NULL, stat = "identity", position = "identity", na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE, ... ) geom_glowstep( mapping = NULL, data = NULL, stat = "identity", position = "identity", direction = "hv", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ... )geom_glowpath( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., lineend = "butt", linejoin = "round", linemitre = 10, arrow = NULL, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_glowline( mapping = NULL, data = NULL, stat = "identity", position = "identity", na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE, ... ) geom_glowstep( mapping = NULL, data = NULL, stat = "identity", position = "identity", direction = "hv", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ... )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer, as a string. |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
... |
Other arguments passed on to |
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
linemitre |
Line mitre limit (number greater than 1). |
arrow |
Arrow specification, as created by |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
orientation |
The orientation of the layer. The default ( |
direction |
direction of stairs: 'vh' for vertical then horizontal, 'hv' for horizontal then vertical, or 'mid' for step half-way between adjacent x-values. |
The group aesthetic determines which cases are
connected together. These functions are designed as a straight replacement
to the geom_path(), geom_line() and geom_step() functions.
To set the order of drawing, make the colour aesthetic a factor, and set the order
from bottom to top.
a ggplot2 layer to add to a plot.
geom_glowpath(): Connects observations in the order in which they appear in the data.
geom_glowline(): Connects observations in order of the variable on the x axis.
geom_glowstep(): Creates a stairstep plot, highlighting exactly when changes occur.
geom_glowpath(), geom_glowline(), and geom_glowstep() handle NA as
follows:
If an NA occurs in the middle of a line, it breaks the line. No warning
is shown, regardless of whether na.rm is TRUE or FALSE.
If an NA occurs at the start or the end of the line and na.rm is FALSE
(default), the NA is removed with a warning.
If an NA occurs at the start or the end of the line and na.rm is TRUE,
the NA is removed silently, without warning.
Adds 3 new aesthetics to geom_path():
shadowcolour defaults to path color, controls the color of the shadow.
shadowlinewidth defaults to linewidth, controls the linewidth of the shadow.
shadowalpha defaults to 0.06 * alpha or 0.06, controls the alpha of the glow.
ggplot2::geom_path(), ggplot2::geom_line(), ggplot2::geom_step():
Filled paths (polygons);
# geom_glowline() is suitable for time series library(ggplot2) ggplot(economics_long, aes(date, value01, colour = variable)) + geom_glowline()# geom_glowline() is suitable for time series library(ggplot2) ggplot(economics_long, aes(date, value01, colour = variable)) + geom_glowline()
The point geom is used to create scatterplots. geom_glowpoint() is designed
as a drop in replacement for geom_point() with an added glow beneath the
point to make a busy plot more aesthetically appealing or to make points
stand out from the rest of the plot.
geom_glowpoint( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_glowpoint( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer, as a string. |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
... |
Other arguments passed on to |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
a layer to add to a plot.
Adds 3 new aesthetics to geom_point():
shadowcolour defaults to the same color as the point, controls the
color of the glow
shadowsize defaults to size, controls the sie of the shadow.
shadowalpha defaults to 0.06 * alpha or 0.06, controls
the alpha of the glow
library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg)) p + geom_shadowpoint()library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg)) p + geom_shadowpoint()
Plot a shadow beneath the connected lines to make it easier to read a chart with several
overlapping observations. geom_shadowpath() connects the observations in the order in which they appear
in the data. geom_shadowline() connects them in order of the variable on the
x axis. geom_shadowstep() creates a stairstep plot, highlighting exactly
when changes occur.
geom_shadowpath( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., lineend = "butt", linejoin = "round", linemitre = 10, arrow = NULL, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_shadowline( mapping = NULL, data = NULL, stat = "identity", position = "identity", na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE, ... ) geom_shadowstep( mapping = NULL, data = NULL, stat = "identity", position = "identity", direction = "hv", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ... )geom_shadowpath( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., lineend = "butt", linejoin = "round", linemitre = 10, arrow = NULL, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_shadowline( mapping = NULL, data = NULL, stat = "identity", position = "identity", na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE, ... ) geom_shadowstep( mapping = NULL, data = NULL, stat = "identity", position = "identity", direction = "hv", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ... )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer, as a string. |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
... |
Other arguments passed on to |
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
linemitre |
Line mitre limit (number greater than 1). |
arrow |
Arrow specification, as created by |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
orientation |
The orientation of the layer. The default ( |
direction |
direction of stairs: 'vh' for vertical then horizontal, 'hv' for horizontal then vertical, or 'mid' for step half-way between adjacent x-values. |
The group aesthetic determines which cases are
connected together. These functions are designed as a straight replacement
to the geom_path(), geom_line() and geom_step() functions.
To set the order of drawing, make the colour aesthetic a factor, and set the order
from bottom to top.
a layer to add to a plot.
geom_shadowpath(): Connects observations in the order in which they appear in the data.
geom_shadowline(): Connects observations in order of the variable on the x axis.
geom_shadowstep(): Creates a stairstep plot, highlighting exactly when changes occur.
geom_shadowpath(), geom_shadowline(), and geom_shadowstep() handle NA as follows:
If an NA occurs in the middle of a line, it breaks the line. No warning
is shown, regardless of whether na.rm is TRUE or FALSE.
If an NA occurs at the start or the end of the line and na.rm is FALSE
(default), the NA is removed with a warning.
If an NA occurs at the start or the end of the line and na.rm is TRUE,
the NA is removed silently, without warning.
Adds 3 new aesthetics to geom_path():
shadowcolour defaults to white, controls the color of the shadow.
shadowlinewidth defaults to 2.5 * linewidth, controls the linewidth of the shadow.
shadowalpha defaults to 0.25 * alpha or 0.9, controls the alpha of the shadow.
ggplot2::geom_path(), ggplot2::geom_line(), ggplot2::geom_step(): Filled paths (polygons);
# geom_shadowline() is suitable for time series library(ggplot2) ggplot(economics_long, aes(date, value01, colour = variable)) + geom_shadowline() ggplot(economics_long, aes(date, value01, colour = value01, group = variable, alpha=date, shadowalpha=1)) + geom_shadowline()# geom_shadowline() is suitable for time series library(ggplot2) ggplot(economics_long, aes(date, value01, colour = variable)) + geom_shadowline() ggplot(economics_long, aes(date, value01, colour = value01, group = variable, alpha=date, shadowalpha=1)) + geom_shadowline()
The point geom is used to create scatterplots. geom_shadowpoint() is
designed as a drop in replacement for geom_point() with an added shadow
beneath the point to make a busy plot more aesthetically appealing or to make
points stand out from the rest of the plot.
geom_shadowpoint( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_shadowpoint( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer, as a string. |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
... |
Other arguments passed on to |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
a layer to add to a plot.
Adds 3 new aesthetics to geom_point():
shadowcolour defaults to white, controls the color of the shadow.
shadowsize defaults to 1.8 * size, controls the size of the
shadow.
shadowalpha defaults to 0.25 * alpha or 0.9, controls
the alpha of the shadow.
library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg)) p + geom_shadowpoint()library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg)) p + geom_shadowpoint()
The brewer scales provides sequential, diverging and qualitative
colour schemes from ColorBrewer. These are particularly well suited to
display discrete values on a map. See https://colorbrewer2.org for
more information.
scale_shadowcolour_brewer( ..., type = "seq", palette = 1, direction = 1, aesthetics = "shadowcolour" ) scale_shadowcolour_distiller( ..., type = "seq", palette = 1, direction = -1, values = NULL, space = "Lab", na.value = "grey50", guide = "colourbar", aesthetics = "shadowcolour" ) scale_shadowcolour_fermenter( ..., type = "seq", palette = 1, direction = -1, na.value = "grey50", guide = "coloursteps", aesthetics = "shadowcolour" )scale_shadowcolour_brewer( ..., type = "seq", palette = 1, direction = 1, aesthetics = "shadowcolour" ) scale_shadowcolour_distiller( ..., type = "seq", palette = 1, direction = -1, values = NULL, space = "Lab", na.value = "grey50", guide = "colourbar", aesthetics = "shadowcolour" ) scale_shadowcolour_fermenter( ..., type = "seq", palette = 1, direction = -1, na.value = "grey50", guide = "coloursteps", aesthetics = "shadowcolour" )
... |
Other arguments passed on to |
type |
One of "seq" (sequential), "div" (diverging) or "qual" (qualitative) |
palette |
If a string, will use that named palette. If a number, will index into
the list of palettes of appropriate |
direction |
Sets the order of colours in the scale. If 1, the default,
colours are as output by |
aesthetics |
Character string or vector of character strings listing the
name(s) of the aesthetic(s) that this scale works with. This can be useful, for
example, to apply colour settings to the |
values |
if colours should not be evenly positioned along the gradient
this vector gives the position (between 0 and 1) for each colour in the
|
space |
colour space in which to calculate gradient. Must be "Lab" - other values are deprecated. |
na.value |
Colour to use for missing values |
guide |
Type of legend. Use |
The brewer scales were carefully designed and tested on discrete data.
They were not designed to be extended to continuous data, but results often
look good. Your mileage may vary.
a scale object to add to a plot.
The following palettes are available for use with these scales:
BrBG, PiYG, PRGn, PuOr, RdBu, RdGy, RdYlBu, RdYlGn, Spectral
Accent, Dark2, Paired, Pastel1, Pastel2, Set1, Set2, Set3
Blues, BuGn, BuPu, GnBu, Greens, Greys, Oranges, OrRd, PuBu, PuBuGn, PuRd, Purples, RdPu, Reds, YlGn, YlGnBu, YlOrBr, YlOrRd
Modify the palette through the palette argument.
The distiller scales extend brewer to continuous scales by smoothly
interpolating 7 colours from any palette to a continuous scale. The fermenter
scales provide binned versions of the brewer scales.
Other colour scales:
scale_colour_hue,
scale_colour_steps,
scale_gradient,
scale_grey,
scale_viridis
library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolor=as.factor(gear))) p + geom_shadowpoint() + scale_shadowcolour_brewer() library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolor=gear)) p + geom_shadowpoint() + scale_shadowcolour_distiller() + guides(shadowcolor='none') library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolor=as.factor(gear))) p + geom_shadowpoint() + scale_shadowcolour_brewer()library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolor=as.factor(gear))) p + geom_shadowpoint() + scale_shadowcolour_brewer() library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolor=gear)) p + geom_shadowpoint() + scale_shadowcolour_distiller() + guides(shadowcolor='none') library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolor=as.factor(gear))) p + geom_shadowpoint() + scale_shadowcolour_brewer()
This is the default colour scale for categorical variables. It maps each level to an evenly spaced hue on the colour wheel. It does not generate colour-blind safe palettes.
scale_shadowcolour_hue( ..., h = c(0, 360) + 15, c = 100, l = 65, h.start = 0, direction = 1, na.value = "grey50", aesthetics = "shadowcolour" ) scale_shadowcolour_discrete( ..., h = c(0, 360) + 15, c = 100, l = 65, h.start = 0, direction = 1, na.value = "grey50", aesthetics = "shadowcolour" )scale_shadowcolour_hue( ..., h = c(0, 360) + 15, c = 100, l = 65, h.start = 0, direction = 1, na.value = "grey50", aesthetics = "shadowcolour" ) scale_shadowcolour_discrete( ..., h = c(0, 360) + 15, c = 100, l = 65, h.start = 0, direction = 1, na.value = "grey50", aesthetics = "shadowcolour" )
... |
Arguments passed on to
|
h |
range of hues to use, in [0, 360] |
c |
chroma (intensity of colour), maximum value varies depending on combination of hue and luminance. |
l |
luminance (lightness), in [0, 100] |
h.start |
hue to start at |
direction |
direction to travel around the colour wheel, 1 = clockwise, -1 = counter-clockwise |
na.value |
Colour to use for missing values |
aesthetics |
Character string or vector of character strings listing the
name(s) of the aesthetic(s) that this scale works with. This can be useful, for
example, to apply colour settings to the |
a scale object to add to a plot.
Other colour scales:
scale_brewer,
scale_colour_steps,
scale_gradient,
scale_grey,
scale_viridis
library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolor=as.factor(gear))) p + geom_shadowpoint() + scale_shadowcolour_hue() library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolor=as.factor(gear))) p + geom_shadowpoint() + scale_shadowcolour_discrete()library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolor=as.factor(gear))) p + geom_shadowpoint() + scale_shadowcolour_hue() library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolor=as.factor(gear))) p + geom_shadowpoint() + scale_shadowcolour_discrete()
scale_*_steps creates a two colour binned gradient (low-high),
scale_*_steps2 creates a diverging binned colour gradient (low-mid-high),
and scale_*_stepsn creates a n-colour binned gradient. These scales are
binned variants of the gradient scale family and
works in the same way.
scale_shadowcolour_steps( ..., low = "#132B43", high = "#56B1F7", space = "Lab", na.value = "grey50", guide = "coloursteps", aesthetics = "shadowcolour" ) scale_shadowcolour_steps2( ..., low = muted("red"), mid = "white", high = muted("blue"), midpoint = 0, space = "Lab", na.value = "grey50", guide = "coloursteps", aesthetics = "shadowcolour" ) scale_shadowcolour_stepsn( ..., colours, values = NULL, space = "Lab", na.value = "grey50", guide = "coloursteps", aesthetics = "shadowcolour", colors )scale_shadowcolour_steps( ..., low = "#132B43", high = "#56B1F7", space = "Lab", na.value = "grey50", guide = "coloursteps", aesthetics = "shadowcolour" ) scale_shadowcolour_steps2( ..., low = muted("red"), mid = "white", high = muted("blue"), midpoint = 0, space = "Lab", na.value = "grey50", guide = "coloursteps", aesthetics = "shadowcolour" ) scale_shadowcolour_stepsn( ..., colours, values = NULL, space = "Lab", na.value = "grey50", guide = "coloursteps", aesthetics = "shadowcolour", colors )
... |
Arguments passed on to
|
low, high
|
Colours for low and high ends of the gradient. |
space |
colour space in which to calculate gradient. Must be "Lab" - other values are deprecated. |
na.value |
Colour to use for missing values |
guide |
Type of legend. Use |
aesthetics |
Character string or vector of character strings listing the
name(s) of the aesthetic(s) that this scale works with. This can be useful, for
example, to apply colour settings to the |
mid |
colour for mid point |
midpoint |
The midpoint (in data value) of the diverging scale. Defaults to 0. |
colours, colors
|
Vector of colours to use for n-colour gradient. |
values |
if colours should not be evenly positioned along the gradient
this vector gives the position (between 0 and 1) for each colour in the
|
Default colours are generated with munsell and
mnsl(c("2.5PB 2/4", "2.5PB 7/10")). Generally, for continuous
colour scales you want to keep hue constant, but vary chroma and
luminance. The munsell package makes this easy to do using the
Munsell colour system.
a scale object to add to a plot.
scales::seq_gradient_pal() for details on underlying
palette
Other colour scales:
scale_brewer,
scale_colour_hue,
scale_gradient,
scale_grey,
scale_viridis
library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolor=gear)) p + geom_shadowpoint() + scale_shadowcolour_steps() + guides(shadowcolour='none') library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolor=gear)) p + geom_shadowpoint() + scale_shadowcolour_steps2() + guides(shadowcolour='none') library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolor=gear)) p <- p + geom_shadowpoint() + scale_shadowcolour_stepsn(colours=c('red', 'yellow')) p + guides(shadowcolour='none')library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolor=gear)) p + geom_shadowpoint() + scale_shadowcolour_steps() + guides(shadowcolour='none') library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolor=gear)) p + geom_shadowpoint() + scale_shadowcolour_steps2() + guides(shadowcolour='none') library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolor=gear)) p <- p + geom_shadowpoint() + scale_shadowcolour_stepsn(colours=c('red', 'yellow')) p + guides(shadowcolour='none')
Colour scales for continuous data default to the values of the
ggplot2.continuous.colour and ggplot2.continuous.fill options. These
options() default to "gradient" (i.e., scale_colour_gradient() and
scale_fill_gradient())
scale_shadowcolour_continuous( ..., type = getOption("ggplot2.continuous.colour", default = "gradient") ) scale_shadowcolour_binned( ..., type = getOption("ggplot2.binned.colour", default = getOption("ggplot2.continuous.colour", default = "gradient")) )scale_shadowcolour_continuous( ..., type = getOption("ggplot2.continuous.colour", default = "gradient") ) scale_shadowcolour_binned( ..., type = getOption("ggplot2.binned.colour", default = getOption("ggplot2.continuous.colour", default = "gradient")) )
... |
Additional parameters passed on to the scale type |
type |
One of the following:
|
a scale object to add to a plot.
Many color palettes derived from RGB combinations (like the "rainbow" color
palette) are not suitable to support all viewers, especially those with
color vision deficiencies. Using viridis type, which is perceptually
uniform in both colour and black-and-white display is an easy option to
ensure good perceptive properties of your visulizations.
The colorspace package offers functionalities
to generate color palettes with good perceptive properties,
to analyse a given color palette, like emulating color blindness,
and to modify a given color palette for better perceptivity.
For more information on color vision deficiencies and suitable color choices see the paper on the colorspace package and references therein.
scale_colour_gradient(), scale_colour_viridis_c(),
scale_colour_steps(), scale_colour_viridis_b(), scale_fill_gradient(),
scale_fill_viridis_c(), scale_fill_steps(), and scale_fill_viridis_b()
library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolor=gear)) p + geom_shadowpoint() + scale_shadowcolour_continuous() + guides(shadowcolour='none') library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolor=gear)) p + geom_shadowpoint() + scale_shadowcolour_binned() + guides(shadowcolour='none')library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolor=gear)) p + geom_shadowpoint() + scale_shadowcolour_continuous() + guides(shadowcolour='none') library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolor=gear)) p + geom_shadowpoint() + scale_shadowcolour_binned() + guides(shadowcolour='none')
scale_*_gradient creates a two colour gradient (low-high),
scale_*_gradient2 creates a diverging colour gradient (low-mid-high),
scale_*_gradientn creates a n-colour gradient.
scale_shadowcolour_gradient( ..., low = "#132B43", high = "#56B1F7", space = "Lab", na.value = "grey50", guide = "colourbar", aesthetics = "shadowcolour" ) scale_shadowcolour_gradient2( ..., low = muted("red"), mid = "white", high = muted("blue"), midpoint = 0, space = "Lab", na.value = "grey50", guide = "colourbar", aesthetics = "shadowcolour" ) scale_shadowcolour_gradientn( ..., colours, values = NULL, space = "Lab", na.value = "grey50", guide = "colourbar", aesthetics = "shadowcolour", colors ) scale_shadowcolour_datetime( ..., low = "#132B43", high = "#56B1F7", space = "Lab", na.value = "grey50", guide = "colourbar" ) scale_shadowcolour_date( ..., low = "#132B43", high = "#56B1F7", space = "Lab", na.value = "grey50", guide = "colourbar" )scale_shadowcolour_gradient( ..., low = "#132B43", high = "#56B1F7", space = "Lab", na.value = "grey50", guide = "colourbar", aesthetics = "shadowcolour" ) scale_shadowcolour_gradient2( ..., low = muted("red"), mid = "white", high = muted("blue"), midpoint = 0, space = "Lab", na.value = "grey50", guide = "colourbar", aesthetics = "shadowcolour" ) scale_shadowcolour_gradientn( ..., colours, values = NULL, space = "Lab", na.value = "grey50", guide = "colourbar", aesthetics = "shadowcolour", colors ) scale_shadowcolour_datetime( ..., low = "#132B43", high = "#56B1F7", space = "Lab", na.value = "grey50", guide = "colourbar" ) scale_shadowcolour_date( ..., low = "#132B43", high = "#56B1F7", space = "Lab", na.value = "grey50", guide = "colourbar" )
... |
Arguments passed on to
|
low, high
|
Colours for low and high ends of the gradient. |
space |
colour space in which to calculate gradient. Must be "Lab" - other values are deprecated. |
na.value |
Colour to use for missing values |
guide |
Type of legend. Use |
aesthetics |
Character string or vector of character strings listing the
name(s) of the aesthetic(s) that this scale works with. This can be useful, for
example, to apply colour settings to the |
mid |
colour for mid point |
midpoint |
The midpoint (in data value) of the diverging scale. Defaults to 0. |
colours, colors
|
Vector of colours to use for n-colour gradient. |
values |
if colours should not be evenly positioned along the gradient
this vector gives the position (between 0 and 1) for each colour in the
|
Default colours are generated with munsell and
mnsl(c("2.5PB 2/4", "2.5PB 7/10")). Generally, for continuous
colour scales you want to keep hue constant, but vary chroma and
luminance. The munsell package makes this easy to do using the
Munsell colour system.
a scale object to add to a plot.
scales::seq_gradient_pal() for details on underlying
palette
Other colour scales:
scale_brewer,
scale_colour_hue,
scale_colour_steps,
scale_grey,
scale_viridis
library( ggplot2 ) p <- ggplot(economics, aes(date, unemploy, shadowcolor=pce)) p + geom_shadowline() + scale_shadowcolour_gradient() + guides(shadowcolour='none') library( ggplot2 ) p <- ggplot(economics, aes(date, unemploy, shadowcolor=pce)) p + geom_shadowline() + scale_shadowcolour_gradient2() + guides(shadowcolour='none') library( ggplot2 ) p <- ggplot(economics, aes(date, unemploy, shadowcolor=pce)) p <- p + geom_shadowline() + scale_shadowcolour_gradientn(colours=c('red', 'green')) p + guides(shadowcolour='none') library( ggplot2 ) p <- ggplot(economics, aes(uempmed, unemploy, shadowcolor=as.POSIXct(date))) p + geom_shadowpath() + scale_shadowcolour_datetime() + guides(shadowcolour='none') library( ggplot2 ) p <- ggplot(economics, aes(uempmed, unemploy, shadowcolor=date)) p + geom_shadowpath() + scale_shadowcolour_date() + guides(shadowcolour='none')library( ggplot2 ) p <- ggplot(economics, aes(date, unemploy, shadowcolor=pce)) p + geom_shadowline() + scale_shadowcolour_gradient() + guides(shadowcolour='none') library( ggplot2 ) p <- ggplot(economics, aes(date, unemploy, shadowcolor=pce)) p + geom_shadowline() + scale_shadowcolour_gradient2() + guides(shadowcolour='none') library( ggplot2 ) p <- ggplot(economics, aes(date, unemploy, shadowcolor=pce)) p <- p + geom_shadowline() + scale_shadowcolour_gradientn(colours=c('red', 'green')) p + guides(shadowcolour='none') library( ggplot2 ) p <- ggplot(economics, aes(uempmed, unemploy, shadowcolor=as.POSIXct(date))) p + geom_shadowpath() + scale_shadowcolour_datetime() + guides(shadowcolour='none') library( ggplot2 ) p <- ggplot(economics, aes(uempmed, unemploy, shadowcolor=date)) p + geom_shadowpath() + scale_shadowcolour_date() + guides(shadowcolour='none')
Based on gray.colors(). This is black and white equivalent
of scale_colour_gradient().
scale_shadowcolour_grey( ..., start = 0.2, end = 0.8, na.value = "red", aesthetics = "shadowcolour" )scale_shadowcolour_grey( ..., start = 0.2, end = 0.8, na.value = "red", aesthetics = "shadowcolour" )
... |
Arguments passed on to
|
start |
grey value at low end of palette |
end |
grey value at high end of palette |
na.value |
Colour to use for missing values |
aesthetics |
Character string or vector of character strings listing the
name(s) of the aesthetic(s) that this scale works with. This can be useful, for
example, to apply colour settings to the |
a scale object to add to a plot.
Other colour scales:
scale_brewer,
scale_colour_hue,
scale_colour_steps,
scale_gradient,
scale_viridis
library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolour=as.factor(gear))) p + geom_glowpoint() + scale_shadowcolour_grey() + guides(shadowcolour='none')library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolour=as.factor(gear))) p + geom_glowpoint() + scale_shadowcolour_grey() + guides(shadowcolour='none')
Use this set of scales when your data has already been scaled, i.e. it
already represents aesthetic values that ggplot2 can handle directly.
These scales will not produce a legend unless you also supply the breaks,
labels, and type of guide you want.
scale_shadowcolour_identity(..., guide = "none", aesthetics = "shadowcolour")scale_shadowcolour_identity(..., guide = "none", aesthetics = "shadowcolour")
... |
Other arguments passed on to |
guide |
Guide to use for this scale. Defaults to |
aesthetics |
Character string or vector of character strings listing the
name(s) of the aesthetic(s) that this scale works with. This can be useful, for
example, to apply colour settings to the |
The functions ggplot2::scale_colour_identity(),
ggplot2::scale_fill_identity(), ggplot2::scale_size_identity(), etc. work
on the aesthetics specified in the scale name: colour, fill, size, etc.
However, the functions scale_colour_identity() and scale_fill_identity()
also have an optional aesthetics argument that can be used to define both
colour and fill aesthetic mappings via a single function call. The
functions scale_discrete_identity() and scale_continuous_identity() are
generic scales that can work with any aesthetic or set of aesthetics provided
via the aesthetics argument.
a scale object to add to a plot.
library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolor='red')) p + geom_shadowpoint() + scale_shadowcolour_identity()library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolor='red')) p + geom_shadowpoint() + scale_shadowcolour_identity()
These functions allow you to specify your own set of mappings from levels in the data to aesthetic values.
scale_shadowcolour_manual( ..., values, aesthetics = "shadowcolour", breaks = waiver() )scale_shadowcolour_manual( ..., values, aesthetics = "shadowcolour", breaks = waiver() )
... |
Arguments passed on to
|
values |
a set of aesthetic values to map data values to. The values
will be matched in order (usually alphabetical) with the limits of the
scale, or with |
aesthetics |
Character string or vector of character strings listing the
name(s) of the aesthetic(s) that this scale works with. This can be useful, for
example, to apply colour settings to the |
breaks |
One of:
|
The functions scale_colour_manual(), scale_fill_manual(), scale_size_manual(),
etc. work on the aesthetics specified in the scale name: colour, fill, size,
etc. However, the functions scale_colour_manual() and scale_fill_manual() also
have an optional aesthetics argument that can be used to define both colour and
fill aesthetic mappings via a single function call (see examples). The function
scale_discrete_manual() is a generic scale that can work with any aesthetic or set
of aesthetics provided via the aesthetics argument.
a scale object to add to a plot.
Many color palettes derived from RGB combinations (like the "rainbow" color
palette) are not suitable to support all viewers, especially those with
color vision deficiencies. Using viridis type, which is perceptually
uniform in both colour and black-and-white display is an easy option to
ensure good perceptive properties of your visulizations.
The colorspace package offers functionalities
to generate color palettes with good perceptive properties,
to analyse a given color palette, like emulating color blindness,
and to modify a given color palette for better perceptivity.
For more information on color vision deficiencies and suitable color choices see the paper on the colorspace package and references therein.
library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolour=as.factor(gear))) p <- p + geom_glowpoint() + guides(shadowcolour='none') p + scale_shadowcolour_manual(values=c('red', 'blue', 'green'))library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolour=as.factor(gear))) p <- p + geom_glowpoint() + guides(shadowcolour='none') p + scale_shadowcolour_manual(values=c('red', 'blue', 'green'))
The viridis scales provide colour maps that are perceptually uniform in both
colour and black-and-white. They are also designed to be perceived by viewers
with common forms of colour blindness. See also
https://bids.github.io/colormap/.
scale_shadowcolour_viridis_d( ..., alpha = 1, begin = 0, end = 1, direction = 1, option = "D", aesthetics = "shadowcolour" ) scale_shadowcolour_viridis_c( ..., alpha = 1, begin = 0, end = 1, direction = 1, option = "D", values = NULL, space = "Lab", na.value = "grey50", guide = "colourbar", aesthetics = "shadowcolour" ) scale_shadowcolour_viridis_b( ..., alpha = 1, begin = 0, end = 1, direction = 1, option = "D", values = NULL, space = "Lab", na.value = "grey50", guide = "coloursteps", aesthetics = "shadowcolour" ) scale_shadowcolour_ordinal( ..., alpha = 1, begin = 0, end = 1, direction = 1, option = "D", aesthetics = "shadowcolour" )scale_shadowcolour_viridis_d( ..., alpha = 1, begin = 0, end = 1, direction = 1, option = "D", aesthetics = "shadowcolour" ) scale_shadowcolour_viridis_c( ..., alpha = 1, begin = 0, end = 1, direction = 1, option = "D", values = NULL, space = "Lab", na.value = "grey50", guide = "colourbar", aesthetics = "shadowcolour" ) scale_shadowcolour_viridis_b( ..., alpha = 1, begin = 0, end = 1, direction = 1, option = "D", values = NULL, space = "Lab", na.value = "grey50", guide = "coloursteps", aesthetics = "shadowcolour" ) scale_shadowcolour_ordinal( ..., alpha = 1, begin = 0, end = 1, direction = 1, option = "D", aesthetics = "shadowcolour" )
... |
Other arguments passed on to |
alpha |
The alpha transparency, a number in [0,1], see argument alpha in
|
begin, end
|
The (corrected) hue in |
direction |
Sets the order of colors in the scale. If 1, the default, colors are ordered from darkest to lightest. If -1, the order of colors is reversed. |
option |
A character string indicating the color map option to use. Eight options are available:
|
aesthetics |
Character string or vector of character strings listing the
name(s) of the aesthetic(s) that this scale works with. This can be useful, for
example, to apply colour settings to the |
values |
if colours should not be evenly positioned along the gradient
this vector gives the position (between 0 and 1) for each colour in the
|
space |
colour space in which to calculate gradient. Must be "Lab" - other values are deprecated. |
na.value |
Missing values will be replaced with this value. |
guide |
A function used to create a guide or its name. See
|
a scale object to add to a plot.
Other colour scales:
scale_brewer,
scale_colour_hue,
scale_colour_steps,
scale_gradient,
scale_grey
library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolour=as.factor(gear))) p + geom_glowpoint() + scale_shadowcolour_viridis_d() + guides(shadowcolour='none') library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolour=gear)) p + geom_glowpoint() + scale_shadowcolour_viridis_c() + guides(shadowcolour='none') library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolour=gear)) p + geom_glowpoint() + scale_shadowcolour_viridis_b() + guides(shadowcolour='none') library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolour=as.factor(gear))) p + geom_glowpoint() + scale_shadowcolour_ordinal() + guides(shadowcolour='none')library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolour=as.factor(gear))) p + geom_glowpoint() + scale_shadowcolour_viridis_d() + guides(shadowcolour='none') library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolour=gear)) p + geom_glowpoint() + scale_shadowcolour_viridis_c() + guides(shadowcolour='none') library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolour=gear)) p + geom_glowpoint() + scale_shadowcolour_viridis_b() + guides(shadowcolour='none') library( ggplot2 ) p <- ggplot(mtcars, aes(wt, mpg, shadowcolour=as.factor(gear))) p + geom_glowpoint() + scale_shadowcolour_ordinal() + guides(shadowcolour='none')