I am using survival analysis to show the proportion of individuals/duration to reach a developmental milestone, and I would like to flip the y-axis ticks so it has 0 at the top and 1.00 at the bottom. I tried using scale_y_reverse, but this flipped the results too. I just want the axis ticks to go from 0-1, while maintaining the visuals of the first graph. Thanks for your help!!
ggsurvplot(spin_fit, data = spin.data, pval = TRUE, conf.int = TRUE)
ggplot2 <- ggsurvplot(spin_fit, data = spin.data, pval = TRUE)$plot
df1 <- data.frame(time=spin_fit$time, nRisk=spin_fit$n.risk, nRiskRel=spin_fit$n.risk/max(spin_fit$n.risk))
ggplot2 + geom_point(aes(x=time, y=nRiskRel), data = df1, alpha=0.5, size=3)
ggplot2 + ylab("Proportion of Larvae Spinning Cocoon") ]
Here's what happened when I added to the last line:
ggplot2 + ylab("Proportion of Larvae Spinning Cocoon") + scale_y_reverse()
You could try to use scale_y_continuous
to set your own breaks and labels:
break_values <- c(0, 0.25, 0.5, 0.75, 1)
ggplot2 + scale_y_continuous(breaks = break_values,
labels = as.character(rev(break_values)))