作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
为什么ggplot会一直给我一个月的第一天,然后再绘制一个时间序列。
这是我的代码示例:
library(ggplot2)
library(dplyr)
date <- as.Date(c("2008-01-31",
"2008-02-29",
"2008-03-31",
"2008-04-30",
"2008-05-31"))
count <- sample(5)
df <- data.frame(date = date, count = count)
df %>%
ggplot(aes(x = date, y = count))+
geom_line()+
scale_x_date(date_breaks = "1 month",
date_labels = '%m/%d')
df
或月份的最后一天的实际日期。而是显示下个月的第一天。
最佳答案
也许最直接的解决方案是直接使用breaks
而不是date_breaks
,直接引用数据框中的日期列。
df %>%
ggplot(aes(x = date, y = count))+
geom_line()+
scale_x_date(date_labels = '%m/%d', breaks = df$date)
关于r - R-ggplot2时间序列x轴,显示当月的最后一天,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49765967/
似乎无法找到答案 - 所以我想我会试一试。 我已经阅读了几个关于如何检测背景事件点击的答案。如:Detect click on background event 然而,我发现当两个或更多背景事件位于同
我在处理插入日期时间值时遇到了一个奇怪的问题。它发生在插入 DATETIME 或 TIMESTAMP 类型的列时,以及使用 STR_TO_DATE 函数时。 当月份、日期、小时或分钟为数字 8 或 9
我是一名优秀的程序员,十分优秀!