Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ggplot2: does boxplot use for calculations only values lying within limits of y-axis?

I noticed that median of boxplot (constructed with restricted ylim-parameter) may differ from the median obtained by median()-function or boxplot without adjusted y-axis.

Does it mean that boxplot use for calculations only values lying within defined interval of y-axis?? And if so, how could I get correct boxplot (based on all values), but plot it on particular interval of y.axis??

Thank you very much.

like image 862
yerba Avatar asked Dec 11 '25 13:12

yerba


1 Answers

Using ylim restricts the scale for y. In ggplot, data that falls outside the scale's limits is discarded and is not included in any statistical computations (such as boxplots). To just zoom the axes without changing the data that is included, use coord_cartesian(ylim=...).

like image 117
Brian Diggs Avatar answered Dec 13 '25 09:12

Brian Diggs