相关疑难解决方法(0)

增加轴刻度数

我正在为一些数据生成图,但是滴答的数量太小,我需要更高的读数精度.

有没有办法增加ggplot2中的轴刻度数?

我知道我可以告诉ggplot使用向量作为轴刻度,但我想要的是增加所有数据的刻度数.换句话说,我希望根据数据计算滴答数.

可能ggplot在内部使用某种算法执行此操作,但我无法找到它是如何做到的,根据我的需要进行更改.

r ggplot2

174
推荐指数
5
解决办法
21万
查看次数

增加ggplot2中日期的轴刻度数

我有一些时间序列数据要绘制,我想要更细粒度的轴刻度.例如:

library(lubridate)
library(ggplot2)
library(scales)

dat <- data.frame(date = paste0("09-01-", gsub(" ", "0", format(1:30))),
                  stringsAsFactors = FALSE)
dat$date <- ymd(dat$date)
dat$y <- rnorm(nrow(dat))

p <- ggplot(dat, aes(x = date, y = y)) + geom_point()
Run Code Online (Sandbox Code Playgroud)

根据这篇文章,我试过了

p  + scale_x_continuous(breaks=pretty_breaks(n=10))
Run Code Online (Sandbox Code Playgroud)

但是Error: Discrete value supplied to continuous scale.关于如何做到这一点的任何想法?

R Under development (unstable) (2014-12-29 r67265)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
Running under: OS X 10.9.5 (Mavericks)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages: …
Run Code Online (Sandbox Code Playgroud)

r ggplot2 lubridate

11
推荐指数
1
解决办法
7068
查看次数

标签 统计

ggplot2 ×2

r ×2

lubridate ×1