Position scales for continuous data (x & y) with labelled vertical/horizontal markers
scale_limitval.Rd
This function is a wrapper around ggplot2::scale_x_continuous()
or
ggplot2::scale_y_continuous()
which allows users to automatically draw
labelled horizontal or vertical markers at specified points. In the air
quality world, this may be particularly useful to display limit values, such
as those defined in legislation or recommended by health authorities.
Usage
scale_y_limitval(
marker_values,
marker_colours = "black",
marker_labels = marker_values,
marker_linetypes = 2,
trans = "identity",
...
)
scale_x_limitval(
marker_values,
marker_colours = "black",
marker_labels = marker_values,
marker_linetypes = 2,
trans = "identity",
...
)
Arguments
- marker_values
Numeric vector of values at which to draw marker lines.
- marker_colours
Character vector of colours for marker lines. Should be the same length as
marker_values
.- marker_labels
Character vector of labels for marker lines. Should be the same length as
marker_values
. Defaults to using the numeric values given inmarker_values
.- marker_linetypes
Vector of values for marker linetypes. Should be the same length as
marker_values
. Defaults to dashed lines (2).- trans
The name of a transformation object. See
ggplot2::scale_x_continuous()
for more information.- ...
Other arguments to pass to
ggplot2::scale_x_continuous()
/ggplot2::scale_y_continuous()
.
Details
This function uses ggplot2::sec_axis()
to display the line labels. One can
therefore not pass ggplot2::sec_axis()
to ...
. If users wish to use
ggplot2::sec_axis()
it is recommended to use ggplot2::geom_abline()
to
draw lines manually.
Unlike other "scale" functions the order in which this function is added to
the ggplot2::ggplot()
object matters. Adding scale_*_limitval()
after ggplot2::geom_line()
will draw the line markers on top of the trend
line, whereas adding it before will draw the markers below.