8

I'm trying to make a simple stacked bar chart, only on the X axis. I have it working, with two values of 50, and 250. So the max of the X axis shows as 300.

How do I force that to another value, like 500? So there is a gap from the last value, to the end of the axis?

In assuming it is via a scale domain somehow? I'm having a tough time understanding all of the options.

1 Answers1

13

You can set the axis limits using the scale domain. Here is an example (vega editor link):

{
  "data": {"values": [{"x": 50, "c": 1}, {"x": 250, "c": 2}]},
  "mark": "bar",
  "encoding": {
    "x": {"field": "x", "type": "quantitative", "scale": {"domain": [0, 500]}},
    "color": {"field": "c", "type": "ordinal"}
  }
}

enter image description here

jakevdp
  • 77,104
  • 11
  • 125
  • 160