r - 如何在同一张图表中制作beanplot和boxplot?

标签 r boxplot

seasons <- structure(list(values = c(204, 339, 304, 434, 334, 212, 361, 
102, 298, 369, 149, 227, 278, 199, 360, 211, 219, 209, 177, 299, 
262, 285, 237, 227, 216, 229, 317, 321, 327, 123, 84, 321, 442, 
263, 225, 290, 259, 219, 244, 325, 257, 672, 762, 381, 698, 578, 
576, 386, 834, 790, 815, 736, 517, 556, 685, 781, 703, 1071, 
537, 784, 753, 790, 489, 878, 433, 742, 638, 731, 1017, 850, 
804, 612, 923, 1000, 855, 750, 921, 676, 621, 781, 703, 1054, 
156, 312, 267, 152, 352, 155, 215, 184, 186, 221, 352, 183, 307, 
353, 507, 255, 159, 109, 343, 377, 209, 260, 193, 231, 111, 167, 
233, 360, 488, 347, 208, 178, 371, 276, 263, 166, 486, 119, 153, 
315, 226, 158, 142, 78, 75, 156, 53, 103, 141, 94, 94, 55, 84, 
35, 82, 65, 150, 30, 201, 184, 94, 119, 150, 70, 63, 50, 74, 
160, 49, 52, 135, 105, 129, 75, 83, 85, 84, 85, 77, 147, 100, 
46), ind = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L), .Label = c("spring", 
"summer", "autumn", "winter"), class = "factor", scores = structure(c(3, 
1, 2, 4), .Dim = 4L, .Dimnames = list(c("autumn", "spring", "summer", 
"winter"))))), .Names = c("values", "ind"), row.names = c(NA, 
-164L), class = "data.frame")

我在下面做了一个箱线图和 bean 图。

boxplot(seasons$values~seasons$ind, ylim= c(0,1200))
beanplot(seasons$values~seasons$ind, ylim= c(0,1200),
     col = c("#CAB2D6", "#33A02C", "#B2DF8A"), border = "#CAB2D6", side="second")

我想制作一个同时包含这些箱线图和 bean 图的图表。 这将使比较变得容易。泰语是我在两个地 block 上制作相同 ylim 的原因。

有什么办法吗?

最佳答案

对于 beanplot 包,使用 add=TRUE:

boxplot(seasons$values~seasons$ind, ylim= c(0,1200))
beanplot(seasons$values~seasons$ind, ylim= c(0,1200), col = c("#CAB2D6", "#33A02C", "#B2DF8A"), border = "#CAB2D6", side="second", add=T)

enter image description here

关于r - 如何在同一张图表中制作beanplot和boxplot?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26214471/

相关文章:

r - 如何对分组的行进行排序,同时将重复项保留在一起

R/exams exams2moodle 不读取数据或源代码

python - 在单个图中,所有列的箱线图被 "label"列分割

python - 如何将seaborn箱线图与具有数组值的数据框一起使用

r - 如何使用stat_boxplot(geom = “errorbar”)更改晶须的线宽

r - 箱线图 - 使用变量访问列名

r - 重新排序因子后正确绘制 xyplot 线

r - 每个参与者都有相同的截距和斜率?

r - 有没有办法在R中制作漂亮的 "flow maps"或 "line area"图?

R Shiny ,无法使用ggplot的 Shiny react 变量设置列名称