File: update_defaults.Rd

package info (click to toggle)
r-cran-ggplot2 4.0.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 11,084 kB
  • sloc: sh: 15; makefile: 5
file content (77 lines) | stat: -rw-r--r-- 2,276 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/geom-defaults.R
\name{update_geom_defaults}
\alias{update_geom_defaults}
\alias{update_stat_defaults}
\alias{reset_geom_defaults}
\alias{reset_stat_defaults}
\title{Modify geom/stat aesthetic defaults for future plots}
\usage{
update_geom_defaults(geom, new)

update_stat_defaults(stat, new)

reset_geom_defaults()

reset_stat_defaults()
}
\arguments{
\item{new}{One of the following:
\itemize{
\item A named list of aesthetics to serve as new defaults.
\item \code{NULL} to reset the defaults.
}}

\item{stat, geom}{Name of geom/stat to modify (like \code{"point"} or
\code{"bin"}), or a Geom/Stat object (like \code{GeomPoint} or
\code{StatBin}).}
}
\description{
Functions to update or reset the default aesthetics of geoms and stats.
}
\note{
Please note that geom defaults can be set \emph{en masse} via the \code{theme(geom)}
argument. The guidelines for when to use which function are as follows:
\itemize{
\item If you want to change defaults for all geoms in all plots, use
\code{theme_update(geom = element_geom(...))}.
\item If you want to change defaults for all geoms in a single plot, use
\code{+ theme(geom = element_geom(...))}.
\item If you want to change defaults for one geom in all plots, use
\code{update_geom_defaults()}.
\item If you want to change settings for one geom in a single plot, use fixed
aesthetic parameters in a layer, like so: \code{geom_point(colour = "red")}.
}
}
\examples{

# updating a geom's default aesthetic settings
# example: change geom_point()'s default color
GeomPoint$default_aes
update_geom_defaults("point", aes(color = "red"))
GeomPoint$default_aes
ggplot(mtcars, aes(mpg, wt)) + geom_point()

# reset single default
update_geom_defaults("point", NULL)

# reset all defaults
reset_geom_defaults()

# updating a stat's default aesthetic settings
# example: change stat_bin()'s default y-axis to the density scale
StatBin$default_aes
update_stat_defaults("bin", aes(y = after_stat(density)))
StatBin$default_aes
ggplot(data.frame(x = rnorm(1e3)), aes(x)) +
  geom_histogram() +
  geom_function(fun = dnorm, color = "red")

# reset single default
update_stat_defaults("bin", NULL)

# reset all defaults
reset_stat_defaults()

}
\keyword{internal}