pirateplot能同时展示原始数据及其相关的统计信息,可以展示1~3个变量之间的关系。

可以同时展示以下四点:

1.点图

2.盒状图

3.密度分布图

4.区间(HDI或者CI)

R包安装:


# Install yarrr from CRAN
install.packages("yarrr")

主要参数:

绘图主题:


pirateplot(formula = weight ~ Time,
           data = ChickWeight,
           theme = 1, # 主题1
           main = "theme = 1")

pirateplot(formula = weight ~ Time,
           data = ChickWeight,
           theme = 2,
           main = "theme = 2")

pirateplot(formula = weight ~ Time,
           data = ChickWeight,
           theme = 3,
           main = "theme = 3")

pirateplot(formula = weight ~ Time,
           data = ChickWeight,
           theme = 4,
           main = "theme = 4")

我们也可以自定义一些参数,如:

代码如下:


pirateplot(formula = weight ~ Time,
           data = ChickWeight,
           theme = 0,                   # 主题
           main = "自定义pirateplot",   # 标题
           pal = "southpark",           # 选择调色板
           # 透明度设置(0~1)
           bean.f.o = .5,               # bean填充
           point.o = .3,                # 点填充
           inf.f.o = .7,                # 区间填充
           inf.b.o = .8,                # 区间宽度
           avg.line.o = 1,              # 均值线
           bar.f.o = .5,                # 盒桩土填充
           # 颜色设置
           inf.f.col = "white",         # 颜色设置
           inf.b.col = "black",         # 同上
           avg.line.col = "black",      # 同上
           bar.f.col = gray(.8),        # 同上
           point.pch = 21,
           point.bg = "white",
           point.col = "black",
           point.cex = .7)

当然还有更多额外的参数也能让pirateplot丰富起来:

大家可以尝试让自己的数据更加生动形象起来。

参考资料:

1.https://cran.r-project.org/web/packages/yarrr/vignettes/pirateplot.html

2.https://github.com/ndphillips/yarrr