【发布时间】:2016-12-26 16:12:24
【问题描述】:
有没有办法在 ggplot 中设置中断步长而不定义序列。例如:
x <- 1:10
y <- 1:10
df <- data.frame(x, y)
# Plot with auto scale
ggplot(df, aes(x,y)) + geom_point()
# Plot with breaks defined by sequence
ggplot(df, aes(x,y)) + geom_point() +
scale_y_continuous(breaks = seq(0,10,1))
# Plot with automatic sequence for breaks
ggplot(df, aes(x,y)) + geom_point() +
scale_y_continuous(breaks = seq(min(df$y),max(df$y),1))
# Does this exist?
ggplot(df, aes(x,y)) + geom_point() +
scale_y_continuous(break_step = 1)
您可能会说我很懒惰,但在某些情况下,由于添加了错误栏,我不得不更改 seq 的 min 和 max 限制。所以我只想说...使用 x 的中断大小,并具有自动比例限制。
【问题讨论】: