【发布时间】:2022-01-24 20:46:00
【问题描述】:
考虑绘图矩阵(例如 3 x 3 散点图网格),其中所有维度共享轴,但不同轴的比例不同(例如,考虑日期、对数数量、线性)。
为此,您可以通过图表规范的 vconcat 和 hconcat 创建一个矩阵。
从文档看来,您应该使用 minExtent 和 maxExtent 来对齐轴,但是我不清楚 在哪里 应用此配置?它需要处于最低图表规范级别,因为轴范围都不同,具体取决于所考虑矩阵的角色和列。
【问题讨论】:
考虑绘图矩阵(例如 3 x 3 散点图网格),其中所有维度共享轴,但不同轴的比例不同(例如,考虑日期、对数数量、线性)。
为此,您可以通过图表规范的 vconcat 和 hconcat 创建一个矩阵。
从文档看来,您应该使用 minExtent 和 maxExtent 来对齐轴,但是我不清楚 在哪里 应用此配置?它需要处于最低图表规范级别,因为轴范围都不同,具体取决于所考虑矩阵的角色和列。
【问题讨论】:
根据docs,您需要在axis配置中提供minExtent和maxExtent。
以下是示例配置或参考editor:
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "Two horizonally concatenated charts that show a histogram of precipitation in Seattle and the relationship between min and max temperature.",
"data": {"url": "data/weather.csv"},
"transform": [{"filter": "datum.location === 'Seattle'"}],
"columns": 3,
"config": {"axisY": {"minExtent": 50, "maxExtent": 100}},
"concat": [
{
"mark": "bar",
"encoding": {
"x": {"timeUnit": "month", "field": "date", "type": "ordinal"},
"y": {
"aggregate": "mean",
"field": "precipitation",
"axis": {"format": ".4f"}
}
}
},
{
"mark": "bar",
"encoding": {
"x": {"timeUnit": "month", "field": "date", "type": "ordinal"},
"y": {"aggregate": "median", "field": "precipitation"}
}
},
{
"mark": "point",
"encoding": {
"x": {"field": "temp_min", "bin": true},
"y": {"field": "temp_max", "bin": true},
"size": {"aggregate": "count"}
}
},
{
"mark": "point",
"encoding": {
"x": {"field": "temp_min", "bin": true},
"y": {"field": "temp_max", "bin": true},
"size": {"aggregate": "count"}
}
},
{
"mark": "point",
"encoding": {
"x": {"field": "temp_min", "bin": true},
"y": {"field": "temp_max", "bin": true},
"size": {"aggregate": "count"}
}
},
{
"mark": "point",
"encoding": {
"x": {"field": "temp_min", "bin": true},
"y": {"field": "temp_max", "bin": true},
"size": {"aggregate": "count"}
}
}
]
}
【讨论】: