R语言10-绘图异常值处理(限制轴)

异常数值出现有很多原因,有的异常值是极端案例的准确数据,有的则为坏数据

异常数值的出现常会造成长尾数据

为避免长尾数据,我们通常对坐标轴进行限制:

  • 方法一:使用xlim,进行限制
library(ggplot2)
qplot(x=friend_count,data = pf,xlim = c(0,1000))
  • 方法二:使用scale_x_continuous (y轴也有scale_y_continuous)
qplot(x=friend_count,data = pf)+scale_x_continuous(limits = c(0,1000))

等效的 ggplot 语法:

ggplot(aes(x = friend_count), data = pf) +
  geom_histogram() +
  scale_x_continuous(limits = c(0, 1000))
发布了14 篇原创文章 · 获赞 0 · 访问量 148

猜你喜欢

转载自blog.csdn.net/xiuxiuxiu666/article/details/104237691