View source: R/scale_symmetric.R
scale_y_symmetric | R Documentation |
Create a symmetric continuous y scale for ggplot2 plots.
The scale ensures that limits set to the range of breaks with zero expand (where symmetric = TRUE
).
Note this scale should only be used in plots with geoms with stat = "identity"
.
Symmetric y continuous scale
scale_y_symmetric(
data = NULL,
y = NULL,
...,
breaks = NULL,
breaks_n = 6,
expand = NULL,
expand_limits = NULL,
labels = NULL,
position = "left",
sec_axis = ggplot2::waiver(),
transform = "identity",
symmetric = TRUE
)
data |
A data frame or tibble. |
y |
An unquoted variable. |
... |
Provided to force user argument naming etc. |
breaks |
A |
breaks_n |
If |
expand |
Padding to the limits with the |
expand_limits |
Any values that the limits should encompass (e.g. |
labels |
A function that takes the breaks as inputs (e.g. |
position |
The position of the axis (i.e. |
sec_axis |
A secondary axis created with |
transform |
A transformation object (e.g. |
symmetric |
|
A ggplot2 continuous y scale.
library(ggplot2)
library(dplyr)
library(palmerpenguins)
set_blanket()
penguins |>
ggplot() +
geom_point(aes(x = flipper_length_mm, y = body_mass_g, colour = species)) +
scale_y_symmetric(penguins, body_mass_g) +
theme(axis.line.y = element_blank()) +
theme(axis.ticks.y = element_blank()) +
theme(panel.grid.major.x = element_blank()) +
coord_cartesian(clip = "off") +
labs(x = "Flipper length mm", y = "Body mass g", colour = "Species")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.