Мои метки осей на 1990 и 2010 гг. Отсутствуют на двух приведенных выше графиках. Я также хочу удалить метки 1980, 2000 и 2020, потому что у меня есть данные только за 1990 и 2010 годы. Я попытался использовать функцию mutate:
df2 <- mutate(Year = Year %>% as.factor())
но в процессе, это исключает охват, который я и строю на графиках своих боксов. Заранее спасибо.
df <- tibble::tribble(
~Year, ~Reach, ~Quantity, ~Bar.Type,
1990, "Reach 1", 24, "Lateral bar",
1990, "Reach 1", 16, "Bar accreted to island",
1990, "Reach 1", 8, "Mid channel bar",
1990, "Reach 2", 47, "Lateral bar",
1990, "Reach 2", 77, "Bar accreted to island",
1990, "Reach 2", 36, "Mid channel bar",
1990, "Reach 3", 18, "Lateral bar",
1990, "Reach 3", 12, "Bar accreted to island",
1990, "Reach 3", 6, "Mid channel bar",
1990, "Reach 4", 16, "Lateral bar",
1990, "Reach 4", 29, "Bar accreted to island",
1990, "Reach 4", 12, "Mid channel bar",
2010, "Reach 1", 21, "Lateral bar",
2010, "Reach 1", 23, "Bar accreted to island",
2010, "Reach 1", 13, "Mid channel bar",
2010, "Reach 2", 48, "Lateral bar",
2010, "Reach 2", 116, "Bar accreted to island",
2010, "Reach 2", 65, "Mid channel bar",
2010, "Reach 3", 17, "Lateral bar",
2010, "Reach 3", 14, "Bar accreted to island",
2010, "Reach 3", 10, "Mid channel bar",
2010, "Reach 4", 16, "Lateral bar",
2010, "Reach 4", 36, "Bar accreted to island",
2010, "Reach 4", 14, "Mid channel bar"
)
ggplot(df, aes(x = Year, Quantity))+
geom_bar(stat = "identity", aes(fill = Bar.Type))+
facet_wrap(~Reach, ncol=2)+
scale_fill_brewer(palette = "Blues",
labels = c("Lateral bar", "Bar accreted to island",
"Mid channel bar"))+
theme_bw(base_size=18) +
theme(
axis.title.x = element_blank(),
axis.title.y = element_text(size=14),
axis.text.x = element_text(size=14),
legend.position = "bottom"
) +
labs(y = "Quantity", fill = "")