在我的 ggplot (见下文)上,我期待scale_y_continuous(breaks=(seq(0, 90, 10)))
将 y 设置在 0 到 90 之间,每隔 10 间隔一次。相反,我没有得到 y 轴或刻度线。
谷歌搜索发现了这个并没有完全解决我的问题:
https://stackoverflow.com/questions/43709180/scale-y-continuous-not-working https://stackoverflow.com/questions/43709180/scale-y-continuous-not-working
using ylim()
允许我更改比例,但不允许我将间隔更改为每 10 个。
这是我的数据的 dput:
structure(list(dval = c(73.2, 76.7, 79.2, 74.9, 74.8, 76.8, 74.7,
74, 77.2, 74.6, 74.2, 72.7), date = structure(c(17646, 17655,
17675, 17681, 17701, 17729, 17743, 17751, 17757, 17778, 17793,
17800), class = "Date")), row.names = c(43215L, 43224L, 43244L,
43250L, 43270L, 43298L, 43312L, 43320L, 43326L, 43347L, 43362L,
43369L), class = "data.frame")
这是我用来尝试绘制的代码:
ggplot(test, aes(date, dval)) +
#scale_y_continuous() should be mking Y between 0 and 90 and spaced every 10, but isnt...
#ylim() works but doesnt set default spacing of 10
scale_y_continuous(breaks=(seq(0, 90, 10))) +
#ylim(0, 80) +
geom_point()+
geom_smooth(method=lm)