r - ggplot 1-column facet wrap的x轴上未对齐的点
问题描述
请检查并建议我如何解决以下脚本生成的两个图的差异:
time1 <- c(
as.POSIXlt("2021-05-02 23:57:29"),
as.POSIXlt("2021-05-02 23:58:29"),
as.POSIXlt("2021-05-02 23:59:29"),
as.POSIXlt("2021-05-03 11:06:00"),
as.POSIXlt("2021-05-03 11:07:00"),
as.POSIXlt("2021-05-03 11:08:00")
)
time2 <- c(
as.POSIXlt("2021-05-02 23:59:29"),
as.POSIXlt("2021-05-02 23:59:29"),
as.POSIXlt("2021-05-02 23:59:29"),
as.POSIXlt("2021-05-03 11:08:00"),
as.POSIXlt("2021-05-03 11:08:00"),
as.POSIXlt("2021-05-03 11:08:00")
)
grp <- c("A","B","C","A","B","C")
cnt <- c(29,1,30,31,2,33)
df1 <- data.frame(time1, grp, cnt)
df2 <- data.frame(time2, grp, cnt)
p1 <- ggplot(df1, aes(x = time1, y = cnt, color = grp)) +
geom_jitter(size = 1.0, show.legend = FALSE) +
facet_wrap(~grp, ncol = 1, shrink = FALSE)
p2 <- ggplot(df2, aes(x = time2, y = cnt, color = grp)) +
geom_jitter(size = 1.0, show.legend = FALSE) +
facet_wrap(~grp, ncol = 1, shrink = FALSE)
绘图 p1 显示点按照它们的 time1 值对齐。在情节 p2 中,点未对齐。
解决方案
推荐阅读
- laravel - 无法锁定 ref 'HEAD':无法解析参考 'refs/heads/master':参考损坏
- sql-server - 从每一行获取最大字段值
- powershell - 在 powershell 中获取 Windows 中 Docker 可用的全局内存最大值
- git - 限制 git 分支的检出(VS2017)
- php - 在 Wordpress 类中调用 add_filter
- daml - 无法通过 JSON API 从 DAML 分类帐中获取分类帐时间
- java - 如何在android的一个recyclerview中选择多个视图..?
- r - 在 R 工作室中插入歌曲
- python - 在python中将诸如data0000172之类的数字重新格式化为172
- node.js - 在 Gitlab 页面上运行 nodejs 应用程序的问题