我有一个数据框,其中两列是日期和销售。日期栏从2012-10-22到2016-09-22不等。我想在2013年1月份绘制销售图表而不创建任何子集。
我用过这个 - ggplot(subsales,AES(日期,spdby))+ geom_line()
是否可以使用ggplot()?
I have plotted the sales per day and look like this-
我想放大,到2013年1月,并希望将该部分提取为新的情节。
答案 0 :(得分:0)
是的,在ggplot中:
library(ggplot2)
subsales <- data.frame(
date = seq(as.Date("2013-1-1"), as.Date("2017-1-1"), by = "day"),
spdby = runif(1462, 2000, 6000)
)
ggplot(subsales, aes(date, spdby)) +
geom_line()
ggplot(subsales, aes(date, spdby)) + geom_line() +
scale_x_date(limits = c(as.Date("2013-1-1"), as.Date("2013-1-31")))
#> Warning: Removed 1431 rows containing missing values (geom_path).