trim vega-lite v3 中未使用的轴外部
trim unused outer parts of the axis in vega-lite v3
我怎样才能“trim”轴并摆脱[-101, 225]
两边的填充,特别是在 Vega-Lite v3 ?
您可以将 scale.domain
与 scale.nice=false
一起使用。这适用于 Vega-Lite v3 和 v4。例如:
{
"$schema": "https://vega.github.io/schema/vega-lite/v3.4.0.json",
"data": {
"values": [
{"label": "A", "value": -101},
{"label": "B", "value": -50},
{"label": "C", "value": 10},
{"label": "D", "value": 116},
{"label": "E", "value": 225}
]
},
"mark": "bar",
"encoding": {
"color": {"field": "label", "type": "nominal"},
"x": {
"field": "value",
"scale": {"domain": [-101, 225], "nice": false},
"type": "quantitative"
},
"y": {"field": "label", "type": "nominal"}
}
}
我怎样才能“trim”轴并摆脱[-101, 225]
两边的填充,特别是在 Vega-Lite v3 ?
您可以将 scale.domain
与 scale.nice=false
一起使用。这适用于 Vega-Lite v3 和 v4。例如:
{
"$schema": "https://vega.github.io/schema/vega-lite/v3.4.0.json",
"data": {
"values": [
{"label": "A", "value": -101},
{"label": "B", "value": -50},
{"label": "C", "value": 10},
{"label": "D", "value": 116},
{"label": "E", "value": 225}
]
},
"mark": "bar",
"encoding": {
"color": {"field": "label", "type": "nominal"},
"x": {
"field": "value",
"scale": {"domain": [-101, 225], "nice": false},
"type": "quantitative"
},
"y": {"field": "label", "type": "nominal"}
}
}