在ggplot图表中,我想在副轴上重新缩放y,以使最小y值等于0,最大y值等于100。
mydata <- data.frame(x = c(0, 1, 2, 3, 4, 5),
y = c(20, 55, 69, 72, 73, 72))
break2 <- seq(0, 100, 10)
library(ggplot2)
ggplot(data = mydata, aes(x = x, y = y)) +
ylim(20, 73) +
geom_point(shape = 21, size = 5, color = "black", fill = "orange", stroke = 1) +
scale_x_continuous(name = 'Number of Contacts') +
scale_y_continuous(name = "Remembered (%)",
sec.axis = sec_axis(trans = ~ (.-min(.)) * 100 / (max(.) - min(.)),
name = "Remembered (Index)", …Run Code Online (Sandbox Code Playgroud)