ggplot2 - ggplot - Using xlim / ylim in ggplot2 - ggplot2 tutorial - ggplot tutorial
> library(ggplot2)
> ggplot(iris,aes(Sepal.Width)) + geom_density() + xlim(1,3.5)
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - ggplot2 tutorial - ggplot tutorial - ggplot2 - ggplot - learn ggplot2 - ggplot2 examples - team
- Using xlim or ylim the plot is not cutted, ggplot subsets the data before calling the stat function (stat_density in this case). You can see it in the warning message.
Warning message:
Removed 19 rows containing non-finite values (stat_density).