Reputation: 3394
p <- ggplot(mtcars, aes(cyl, mpg)) +
geom_point()
# Create a simple secondary axis
p + scale_y_continuous("m1", sec.axis = sec_axis(~ . + 10, name = ("m2")))
As you can see "m1" and "m2" is facing towards the figure I am wondering how can I rotate "m2" 90-degrees? So it faces in the same orientation as "m1"? I tried using "rotate" but it's not allowed in sec.axis.
Upvotes: 0
Views: 185
Reputation: 1089
Try this
ggplot(mtcars, aes(cyl, mpg)) +
geom_point() +
scale_y_continuous("m1", sec.axis = sec_axis(~ . + 10, name = ("m2"))) +
theme(axis.title.y.right = element_text(angle=90))
Upvotes: 2