Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting a maximum axis value in Vega lite

Tags:

vega-lite

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.

like image 614
Andrew Crouthamel Avatar asked Mar 13 '19 03:03

Andrew Crouthamel


1 Answers

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

like image 174
jakevdp Avatar answered Nov 07 '22 20:11

jakevdp