我不确定是否有意义,但是可以在绘图的起点和X轴之间添加一个换行符。
例如
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"width": {"step": 10},
"height": 120,
"data": {"url": "data/cars.json"},
"mark": "area",
"encoding": {
"x": {"field": "Name", "type": "nominal", "scale": {"round": false}},
"y": {"aggregate": "count", "type": "quantitative"}
}
}
答案 0 :(得分:1)
一种方法是添加一个scale.domain
参数:
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"width": {"step": 10},
"height": 120,
"data": {"url": "data/cars.json"},
"mark": "area",
"encoding": {
"x": {"field": "Name", "type": "nominal", "scale": {"round": false}},
"y": {"aggregate": "count", "type": "quantitative", "scale": {"domain": [-0.5, 6]}}
}
}
另一种方法是使用y
和y2
编码来设置面积图的底值:
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"width": {"step": 10},
"height": 120,
"data": {"url": "data/cars.json"},
"mark": "area",
"transform": [{"calculate": "0.1", "as": "bottom"}],
"encoding": {
"x": {"field": "Name", "type": "nominal", "scale": {"round": false}},
"y": {"aggregate": "count", "type": "quantitative"},
"y2": {"field": "bottom"}
}
}
答案 1 :(得分:0)
另一种类似的方法,将其添加为另一个答案,以方便其他人使用。
axis的 select t.*,
(case when lag(input, 1, input) over (partition by person_id order by start_date) = input
then 0 else 1
end) as FLAG
from table t;
属性将轴线移动固定像素,与数据无关。不过,使用offset
会在offset
和x
轴线之间添加一个间隙。
y