Basic Vega-Lite Example

In [1]:
import pandas as pd
df = pd.read_json('cars.json')
In [2]:
df.head()
Out[2]:
Name Miles_per_Gallon Cylinders Displacement Horsepower Weight_in_lbs Acceleration Year Origin
0 chevrolet chevelle malibu 18.0 8 307.0 130.0 3504 12.0 1970 USA
1 buick skylark 320 15.0 8 350.0 165.0 3693 11.5 1970 USA
2 plymouth satellite 18.0 8 318.0 150.0 3436 11.0 1970 USA
3 amc rebel sst 16.0 8 304.0 150.0 3433 12.0 1970 USA
4 ford torino 17.0 8 302.0 140.0 3449 10.5 1970 USA
In [3]:
from vega import VegaLite
In [4]:
VegaLite({
  "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
  "mark": "point",
  "encoding": {
    "y": {"type": "quantitative", "field": "Acceleration"},
    "x": {"type": "quantitative", "field": "Horsepower"}
  }
}, df)
Out[4]:
In [ ]: