I have a data.frame(tt)
with 3 columns:
nazvReki
- grouping variable (18 values);rang
- axis X (443 entries from 1 to 70. It takes values from 1 to 70, but for different grouping variables it is different, where 8, where 10, where 16...);procent
- axis Y (0-100 %).
I'm drawing a picture:
ggplot(tt) +
geom_line(aes(rang, procent)) +
scale_x_continuous(
name = c("Rang"),
breaks = scales::pretty_breaks(n = 10)
) +
scale_y_continuous(name = c("Procent")) +
facet_wrap( ~ nazvReki, nrow = 4, scales = "free_x") +
theme_bw()
I need the values to start with 1, and that there are no vertical lines between the numbers.
I do it a little differently:
tt$rang <- factor(tt$rang)
ggplot(tt, aes(rang, procent)) +
geom_line(aes(group = nazvReki)) +
scale_x_discrete(name = c("Rang")) +
scale_y_continuous(name = c("Procent")) +
facet_wrap( ~ nazvReki, nrow = 4, scales = "free_x") +
theme_bw()
It turns out better:
But not all the numbers fit. I play with the parameters, make several options, combine them in a graphic editor. The result is almost perfect
What is missing for perfection? So that on the X-axis the school always starts with 1 and ends with the maximum value, 5-8 values can be inserted between them. And it was all done automatically.
And the question is: can this be done in ggplot2?