就像这个: https://www.r-graph-gallery.com/265-grouped-boxplot-with-ggplot2/
我尝试过刻面,色彩通道和构图, 但效果不佳。
我的用例很容易比较分组平均值,因此我需要并排组合箱形图
答案 0 :(得分:0)
您可以结合使用列编码和x编码。这是一个有关vega数据集填充数据(vega editor link)的示例:
{
"data": {"url": "data/population.json"},
"mark": {
"type": "boxplot",
"extent": "min-max"
},
"encoding": {
"column": {"field": "age","type": "ordinal"},
"y": {
"field": "people",
"type": "quantitative",
"axis": {"title": "population"}
},
"x": {
"field": "sex",
"type": "nominal"
},
"color": {
"field": "sex",
"type": "nominal"
}
}
}