I am a beginner with R and ggplot and have been facing an issue with defining my x and y axis on a linegraph.
I have the following dataset called UK:
I want to plot the beds ratio evolution with
- x axis from 2010 to 2021 with breaks of 1
- y axis from 0 to 3 with break of 0,5
I coded the following:
ggplot(data=UK, aes(x = Year, y = Beds_1000, group = 1)) +
geom_line(color = as.factor("red")) +
geom_point() +
scale_x_discrete(limits=c(2010,2021)) +
scale_y_discrete(limits=c(0,3)
However, the axis of my graph disappear and I get the following message:
Continuous limits supplied to discrete scale. ℹ Did you mean
limits = factor(...)
orscale_*_continuous()
?
I tried using limits=factor()
and scale_*_continuous()
but it made no difference on the final graph. The axis disapear or stay the same as without those functions.