Search code examples
rtime-serieslimitaxis

Set limits in ggplot without loosing data points


I want to focus on certain numbers above 0 in the y axis, so I tried to use

ylim(ymin=0,ymax=15)

but by doing this I removed values that are not in the figure I tried to find another argument that will only "zoom" the figure but do not remove any actual value and the line will remain

Does anyone know any argument that will be valid?

E.g. figures enter image description here enter image description here


Solution

  • Try to use this instead of ylim()

    coord_cartesian(ylim=c(0, 15))