Difference in coord_cartesian and scale_y_continuous



I am currently trying to plot a boxplot using a ggplot2 package of R. I am plotting a factor variable on the x-axis and continuous variable on the y-axis.

I have used two type of layer in my plot.



I want to know the difference between this two layer because I am getting slightly different plots.


scale_y_continuous is used for subsetting the data with the help of xlim and ylim
coord_cartesian is used to zoom in on a plot programatically

I tried your code on a sample data set and it is giving me the same result

Can you be more specific?