scale_y_continuous(limits = c(10, 30)) 与手动设置刻度位置不同,手动设置范围可能会导致数据的失真,因此应该谨慎使用。通常情况下,应该让 ggplot2 自动计算 y 轴范围,以保持数据的真实性。 3. 调整样式 3.1 调整标签 通过设置 labels 参数,可以调整 y 轴的刻度标签。例如,以下代码将 y 轴刻度标签设置为 ...
{ scale_y_continuous(expand = expansion(0, 0.05), ...) } This is in the same spirit as ylab() or ylim(). Thinking a bit further maybe this could even be an option: exact_ylim <- function(...) { scale_y_continuous(limits = c(...), expand = expansion()) } This would ...