This function is used in conjunction with a position scale to create a secondary axis, positioned opposite of the primary axis. All secondary axes must be based on a one-to-one transformation of the primary axes.
sec_axis(trans = NULL, name = waiver(), breaks = waiver(), labels = waiver()) dup_axis(trans = ~., name = derive(), breaks = derive(), labels = derive()) derive()
trans | A transformation formula |
---|---|
name | The name of the secondary axis |
breaks | One of:
|
labels | One of:
|
sec_axis
is used to create the specifications for a secondary axis.
Except for the trans
argument any of the arguments can be set to
derive()
which would result in the secondary axis inheriting the
settings from the primary axis.
dup_axis
is provide as a shorthand for creating a secondary axis that
is a duplication of the primary axis, effectively mirroring the primary axis.
p <- ggplot(mtcars, aes(cyl, mpg)) + geom_point() # Create a simple secondary axis p + scale_y_continuous(sec.axis = sec_axis(~.+10))# Inherit the name from the primary axis p + scale_y_continuous("Miles/gallon", sec.axis = sec_axis(~.+10, name = derive()))