How to plot multiple variables on an axis using Vega-Lite?

Following the Vega Lita weather guide in Seattle, it was easy to build the average temperature per month:

{ "$schema": "https://vega.imtqy.com/schema/vega-lite/v2.json", "data": { "url": "https://vega.imtqy.com/vega-lite/data/seattle-weather.csv" }, "mark": "line", "encoding": { "x": { "timeUnit": "month", "field": "date", "type": "temporal" }, "y": { "aggregate": "mean", "field": "temp_min", "type": "quantitative" } } } 

This dataset also has a temp_max variable. How can I plot both temp_min and temp_max along the y axis?

+1
source share
1 answer

You can use layering as described in https://vega.imtqy.com/vega-lite/docs/layer.html .

 { "data": {"url": "data/seattle-weather.csv"}, "layer": [ { "mark": "line", "encoding": { "x": { "timeUnit": "month", "field": "date", "type": "temporal" }, "y": { "aggregate": "mean", "field": "temp_min", "type": "quantitative" } } }, { "mark": "line", "encoding": { "x": { "timeUnit": "month", "field": "date", "type": "temporal" }, "y": { "aggregate": "mean", "field": "temp_max", "type": "quantitative" } } } ] } 

layered chart

+4
source

Source: https://habr.com/ru/post/1270735/


All Articles