基数为R的分类散点图

时间:2017-02-25 20:54:48

标签: r

是否有一种简单的方法可以用基数R进行分类散点图?

我希望X轴标签是下面的三个列标签。谢谢!

SW-SE        North-SW    North-SE
0.0322791   0.0466558   0.05533
0.0300673   0.0503937   0.0590444
0.0302151   0.0562131   0.0612469
0.0242698   0.068037    0.0756064
0.0315696   0.0440456   0.0449465
0.0273471   0.0485332   0.048216
0.0249796   0.055911    0.0529762
0.0219699   0.0663013   0.0651523
0.0173046   0.0467941   0.049092
0.0224143   0.0507807   0.0526732
0.0245645   0.0554949   0.0567835
0.020624    0.0691155   0.0705431
0.0208465   0.0340491   0.0525786
0.0160655   0.0382029   0.0561054
0.0236193   0.0441057   0.0597504
0.0280541   0.0561134   0.0741485
0.0242048   0.0420126   
0.0243629   0.0459014   
0.0192736   0.0476303   
0.0268329   0.0620177   

1 个答案:

答案 0 :(得分:1)

我认为你要求的是像抖动的散点图。我个人只喜欢这些背后的箱形图,所以这里是:

df = read.table(text =
  "SW-SE        North-SW    North-SE
  0.0322791   0.0466558   0.05533
  0.0300673   0.0503937   0.0590444
  0.0302151   0.0562131   0.0612469
  0.0242698   0.068037    0.0756064
  0.0315696   0.0440456   0.0449465
  0.0273471   0.0485332   0.048216
  0.0249796   0.055911    0.0529762
  0.0219699   0.0663013   0.0651523
  0.0173046   0.0467941   0.049092
  0.0224143   0.0507807   0.0526732
  0.0245645   0.0554949   0.0567835
  0.020624    0.0691155   0.0705431
  0.0208465   0.0340491   0.0525786
  0.0160655   0.0382029   0.0561054
  0.0236193   0.0441057   0.0597504
  0.0280541   0.0561134   0.0741485
  0.0242048   0.0420126   NA
  0.0243629   0.0459014   NA
  0.0192736   0.0476303   NA
  0.0268329   0.0620177   NA",
  header = TRUE
)

jitter = 0.1
boxplot(df, at = c(1, 2, 3))
points(runif(20)*jitter - jitter/2 + 1, df$SW.SE)
points(runif(20)*jitter - jitter/2 + 2, df$North.SW)
points(runif(20)*jitter - jitter/2 + 3, df$North.SE)

有效地boxplot设置了所有内容,您可以使用at参数控制位置,这样也可以让以后使用points轻松排列抖动的散点图,就像plot一样1}}但它增加了现有的数字。

jittered boxplot

抖动很重要的原因是,如果你有多个(接近)相同的y值,它们会被抖动略微分开,你可以更容易区分它们。

我更喜欢抖动背后的箱形图的原因是我可以比精神上寻找中位数和四分位数更容易看到分布。