vega-lite:如何将图例分成多列

时间:2016-12-01 18:03:36

标签: vega-lite

考虑以下设想的例子:

{
  "data": {"url": "data/cars.json"},
  "mark": "point",
  "encoding": {
    "x": {"field": "Horsepower","type": "quantitative"},
    "y": {"field": "Origin","type": "nominal"},
    "color": {"field": "Miles_per_Gallon","type": "ordinal"}
  }
}

数据集有Miles_per_Gallon的许多值,因此color图例将包含许多元素,并且会比图本身大得多。

有没有办法在多个列中显示此图例,而不是单个列?

1 个答案:

答案 0 :(得分:1)

您可以使用每加仑英里数作为定量变量。

{
  "data": {"url": "data/cars.json"},
  "mark": "point",
  "encoding": {
    "x": {"field": "Horsepower","type": "quantitative"},
    "y": {"field": "Origin","type": "nominal"},
    "color": {"field": "Miles_per_Gallon","type": "quantitative"}
  }
}