[英]How does one specify time interval axis on facet_wrap function in ggplot2?
I am using this package for data analysis: https://cran.r-project.org/web/packages/wq/vignettes/wq-package.html 我正在使用此软件包进行数据分析: https : //cran.r-project.org/web/packages/wq/vignettes/wq-package.html
And the section for plotTs uses facet_wrap
function in ggplot2 , the example has a 5 year interval breakdown on automatic. 和用于plotTs的部分使用
facet_wrap
功能在GGPLOT2,示例有自动5年的时间间隔击穿。 My data is only 17 years, so my intervals are very useless with 5 year plots. 我的数据只有17年,所以我的间隔对于5年的情节是非常无用的。 First year is 1996 and last 2013, so is there to specify the breakdown of intervals specific to my case?
第一年是1996年,最后一个是2013年,那么是否要具体说明我的案例的间隔时间?
plotTs(y[, 1:4], dot.size = 1.3, ylab = "Chlorophyll in San Francisco Bay",
strip.labels = paste("Station", 21:24), ncol = 1, scales = "free_y")
Since wq is using ggplot2, you could use scale_x_date()
. 由于wq使用ggplot2,因此可以使用
scale_x_date()
。 Consider this: 考虑一下:
data(sfbay)
sfb <- wqData(sfbay, c(1, 3:4), 5:12, site.order = TRUE,
type = "wide", time.format = "%m/%d/%Y")
y <- tsMake(sfb, focus = "chl", layer = c(0, 5))
y[1:4, ]
plotTs(y[, 1:4], dot.size = 1.3, ylab = "Chlorophyll in San Francisco Bay",
strip.labels = paste("Station", 21:24), ncol = 1, scales = "free_y") +
scale_x_date(date_breaks = "7 years", date_labels = "%Y")
you can play with date_breaks()
and date_labels
. 您可以使用
date_breaks()
和date_labels
。 For more information on scale_x_date()
see http://docs.ggplot2.org/current/scale_date.html 有关
scale_x_date()
更多信息,请参见http://docs.ggplot2.org/current/scale_date.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.