Vega Lite: symlog scale with more tick marks

Viewed 136

Is there a way to use the symlog scale, but with tick marks placed on many orders of magnitude?

To explain, the log scale has tick marks on many orders of magnitude, but cannot show ≤ 1 values (last bar is hidden in this example):

enter image description here

On the other hand, symlog scale can represent negative, zero, and one-valued data, but by default only has tick marks for the largest order of magnitude:

enter image description here

1 Answers

You can specify a list of desired tick values using the axis.values specification. For example:

{
  "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

Related