如何使水平轴居中

How to center the horizontal axis

是否可以将水平轴垂直居中?正值位于轴的顶部,负值位于底部。

我找不到这样的例子。

您可以使用 axis.offset 属性 来完成此操作。例如 (open in editor):

{
  "width": 300,
  "height": 150,
  "data": {"sequence": {"start": 0, "stop": 12.7, "step": 0.1, "as": "x"}},
  "transform": [{"calculate": "sin(datum.x)", "as": "sin(x)"}],
  "mark": "line",
  "encoding": {
    "x": {
      "field": "x",
      "type": "quantitative",
      "axis": {"offset": -75, "grid": false}
    },
    "y": {"field": "sin(x)", "type": "quantitative", "axis": {"grid": false}}
  },
  "view": {"stroke": 0}
}