有没有办法在 x 轴上显示所有日期?我有以下数据集,我想要一个 ggplot,其中在 x 轴上year_month
是列,在 y 轴上是count
列,但我希望它以比例显示所有月份,而不仅仅是像 ggplot2 通常那样做。
library(ggplot2)
library(lubridate)
library(tsibble)
library(dplyr)
plt = structure(list(month = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), year = c(2010,
2012, 2012, 2012, 2013, 2013, 2014, 2014, 2014, 2014, 2014, 2014,
2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014,
2014, 2014, 2014, 2014, 2014, 2014, 2014), website = c("efarsas",
"efarsas", "efarsas", "efarsas", "efarsas", "efarsas", "boatos_org",
"boatos_org", "boatos_org", "boatos_org", "boatos_org", "boatos_org",
"boatos_org", "boatos_org", "boatos_org", "boatos_org", "boatos_org",
"boatos_org", "boatos_org", "boatos_org", "boatos_org", "boatos_org",
"boatos_org", "boatos_org", "boatos_org", "boatos_org", "boatos_org",
"boatos_org", "boatos_org", "boatos_org"), count = c(1L, 3L,
3L, 3L, 2L, 2L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L,
31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 31L,
31L, 31L), year_month = structure(c(14610, 15340, 15340, 15340,
15706, 15706, 16071, 16071, 16071, 16071, 16071, 16071, 16071,
16071, 16071, 16071, 16071, 16071, 16071, 16071, 16071, 16071,
16071, 16071, 16071, 16071, 16071, 16071, 16071, 16071), class = c("yearmonth",
"vctrs_vctr"))), row.names = c(NA, -30L), groups = structure(list(
month = c(1, 1, 1, 1), year = c(2010, 2012, 2013, 2014),
website = c("efarsas", "efarsas", "efarsas", "boatos_org"
), .rows = structure(list(1L, 2:4, 5:6, 7:30), ptype = integer(0), class = c("vctrs_list_of",
"vctrs_vctr", "list"))), row.names = c(NA, 4L), class = c("tbl_df",
"tbl", "data.frame"), .drop = TRUE), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"))
我试过了
plt %>%
ggplot() +
geom_line(aes(x = year_month, y= count, color = website)) +
labs(color = "Fact-Checking Websites",
x = "Month/Year (2010-2020)",
y = "Quantity")+
theme_minimal()
但没有取得成功,因为它只显示了一些years months
写在 x 轴上的内容。