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

99封情书 提交于 2019-12-04 04:34:07

问题


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.


回答1:


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=...).



来源:https://stackoverflow.com/questions/11213455/ggplot2-does-boxplot-use-for-calculations-only-values-lying-within-limits-of-y

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!