Vega Lite:具有更多刻度线的符号比例

时间:2020-11-11 17:46:32

标签: vega-lite vega

有没有一种方法可以使用符号比例尺,但刻度上有多个刻度?

为解释起见, log 刻度在许多数量级上都具有刻度线,但不能显示≤1个值(此示例中的最后一个条被隐藏了):

enter image description here

另一方面,符号刻度可以表示负值,零值和一值数据,但是默认情况下,刻度仅代表最大数量级:

enter image description here

1 个答案:

答案 0 :(得分:1)

您可以使用axis.values规范指定所需的报价值列表。例如:

{
  "mark": "point",
  "data": {
    "values": [
      {"x": 0, "y": 1},
      {"x": 1, "y": 10},
      {"x": 2, "y": 100},
      {"x": 3, "y": 1000},
      {"x": 4, "y": 10000},
      {"x": 5, "y": 100000},
      {"x": 6, "y": 1000000},
      {"x": 7, "y": 10000000}
    ]
  },
  "encoding": {
    "x": {"field": "x", "type": "quantitative"},
    "y": {
      "field": "y",
      "axis": {"values": [10, 100, 1000, 10000, 100000, 1000000, 10000000]},
      "scale": {"type": "symlog", "constant": 1}
    }
  }
}

enter image description here