vega-lite: Error bar macro for value + error

Commonly users come with data of the form value, error. Our errorbar macro should support this use case and not require users to create a transform.

mark: "errorbar",
encoding: {
  y: {field: value, type: "quantitative"},
  yError: {field: error, type: "quantitative"}
}
{
  "data": {
    "values": [
      {
        "yield_error": 3,
        "yield": 32.4,
        "variety": "Glabron"
      },
      {
        "yield_error": 3.2,
        "yield": 30.96667,
        "variety": "Manchuria"
      },
      {
        "yield_error": 1.2,
        "center": 33.966665,
        "variety": "No. 457"
      },
      {
        "yield_error": 2,
        "yield": 30.45,
        "variety": "No. 462"
      }
    ]
  },
  "layer": [
    {
      "mark": "errorbar",
      "encoding": {
        "x": {
          "field": "yield",
          "type": "quantitative",
          "scale": {"zero": false},
          "title": "yield"
        },
        "xError": {"field": "yield_error", "type": "quantitative"},
        "y": {"field": "variety", "type": "ordinal"}
      }
    },
    {
      "mark": {
        "type": "point",
        "filled": true,
        "color": "black"
      },
      "encoding": {
        "x": {
          "field": "yield",
          "type": "quantitative"
        },
        "y": {"field": "variety", "type": "ordinal"}
      }
    }
  ]
}

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 31 (31 by maintainers)

Most upvoted comments

The question is whether the length of the error bar is 2*error or just error.

Actually, it’d be best if the user specified the t to apply. Depending on the number of observations, the acceptable error margin and the underlying distribution, the factor may be well different from 2.

For the short version, it’s actually @domoritz who suggested that people want to add error bar to points, not the other way around.