2017-07-18 20 views
1

は、月ごとに平均分温度をプロットするのは簡単だった:Vega-Liteで軸に複数の変数をプロットする方法は?ベガ・ライトのシアトルの天気チュートリアル後

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

このデータセットはまたtemp_max変数を持っています。 temp_mintemp_maxの両方をy軸にプロットするにはどうすればよいですか?

答えて

4

https://vega.github.io/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

関連する問題