向R中的箱线图添加图案

蓝色

早上好,

我正在寻找一种在我的箱形图上添加图案的方法。我已经看到一些解决方案已经存在(例如此处),但我也找到了一种更为严格的方法(此处)。但是,我无法复制此处给出的示例。

structure(list(day = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("d0", 
"db"), class = "factor"), name = structure(1:20, .Label = c("x1", 
"x2", "x3", "x4", "x5", 
"x6", "x7", "x8", "x9", 
"x10", "x11", "x12", "x13", 
"x14", "x15", "x16", "x17", 
"x18", "x19", "x20", "x21", "x22", 
"x23", "x24", "x25", "x26", 
"x27", "x28", "x29", "x30", 
"x31", "x32", "x33", "x34", 
"x35", "x36", "x37", "x38", "x39"
), class = "factor"), mean = c(36.6, 36.2636363636364, 36.9285714285714, 
35.325, 37.0692307692308, 37.2357142857143, 36.85, 36.0153846153846, 
35.6384615384615, 36.76, 36.8538461538462, 35.4307692307692, 
35.3, 36.8153846153846, 36.1666666666667, 37.775, 37.3733333333333, 
36.4666666666667, 36.6071428571429, 36.6)), row.names = c(NA, 
-20L), class = c("grouped_df", "tbl_df", "tbl", "data.frame"), vars = "day", drop = TRUE, indices = list(
    0:19), group_sizes = 20L, biggest_group_size = 20L, labels = structure(list(
    day = structure(1L, .Label = c("d0", "db"), class = "factor")), row.names = c(NA, 
-1L), class = "data.frame", vars = "day", drop = TRUE))

到目前为止,我所掌握的是以下几行:

patternboxplot(data=temp_mean, x=temp_mean$day, y = temp_mean$mean, group = NULL,
                  pattern.type = c('nwlines', 'blank'), pattern.line.size = c(6,1), 
                  pattern.color = c('black', 'white'),
                  background.color = c('white', 'white'),
                  frame.color = c('black', 'black'),
                  density=c(6,1))

运行它时,出现以下错误:

“ imagetodf2中的错误(readPNG(粘贴(位置,“ /”,pattern.type [i],“。png” ,:找不到对象'xmin'“)。

如果有人对此有任何线索,我将很高兴听到它!

先感谢您。

编辑:我想绘制下图(使用完全相同的数据集和gglpot2在这里获得

在此处输入图片说明

笨狼

模拟类似您的数据的内容:

temp_mean = data.frame(
  day = sample(c("d0","db"),100,replace=TRUE),
  mean = rnorm(100)
)

我尝试过但无法使它们具有不同的填充,每个x轴中断都有组。您可以尝试以下操作(可能不理想):

 patternboxplot(data=temp_mean, x=1, y = temp_mean$mean, group = temp_mean$day,
               pattern.type = c('nwlines', 'blank'), pattern.line.size = c(6,1), 
               pattern.color = c('black', 'white'),
               background.color = c('white', 'white'),
               frame.color = c('black', 'black'),
               density=c(6,1),
               legend.h=30,legend.w=0.05,legend.x.pos=1.075, 
               legend.y.pos=0.88, 
               legend.pixel=10)

在此处输入图片说明

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章