View source: R/scales-defaults.R
scale_ggsvg_default | R Documentation |
Automatically add a default scale for SVG CSS aesthetics
scale_ggsvg_default(p, verbose = FALSE)
p |
|
verbose |
Be verbose about what scales are being created? Logical. Default: FALSE |
ggplot2
object with default scale_svg_*()
added to
the plot environment so that ggplot2
will find these
scales.
If a scale for a particular aesthetic is not explicitly given, then
ggplot2
guesses which scales to use based upon two things:
The aesthetic being mapped e.g. fill
The type of data that is being mapped e.g. continuous
, discrete
,
date
etc
For regular ggplot2
plots, the combination of all these factors have
scales included in the ggplot2
package e.g. scale_fill_continous
,
scale_linetype_discrete
.
However, for ggsvg
, using css()
aesthetics means that there
are a very large number of aesthetics being mapped to i.e not just fill
and colour
, but also stroke-width
, angle
and many other
CSS parameters.
Furthermore, CSS selectors are used to target the aesthetic, and since
there are an infinite number of valid CSS selectors, there will be an
infinite number of scales needed to be provided by ggsvg
.
Fortunately, the majority of things we want to map to in SVG are either
colours or numbers, which means that we can create a single colour
scale
for use with ggsvg
and just change its name, then add it to the plot
environment so that ggplot2
can find it when it renders the plot.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.