简体   繁体   English

R ggplot2:可以自定义时间刻度的连续性吗?

[英]R ggplot2: possible to customize the continuity of a time scale?

Is it possible to have a datetime scale not consider weekends as part of the time continuum? 是否有可能不将周末视为时间连续性的一部分的日期时间刻度? For instance, if I am plotting stock prices over a 2 week period with a line geometry, I do not want to plot a 2 day period of flattness during the weekend. 例如,如果我用线几何图绘制两个星期内的股票价格,我不想在周末绘制一个两天的扁平化期间。 I would like friday to connect with Monday. 我想星期五与星期一联系。

I imagine that there's a better way, but you could always just use an index for the plot and then assign the dates as labels afterwards: 我想这是一种更好的方法,但是您始终可以只为图使用索引,然后再将日期分配为标签:

p <- qplot(1:3, 1:3, geom='line') 
p + scale_x_continuous("", breaks=1:3, labels = as.Date(c("2010-06-03", "2010-06-04", "2010-06-07")))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM