encodeYdirectives map the two quantitative columns Acceleration and HorsePower to the X and Y axes. Then, we say that we want to bin the Acceleration variable, and for each bin, find the man Horsepower. Finally we tell Vegas to break up the dataset by the number of cylinders which is a categorical variable, via the
encodeColordirective. Note the Vegas automatically does the binning and the aggregation, and produces the color-coding together with the legend.
Vegas("Sample Area Chart", width=800, height=600) .withURL(Cars) .mark(Area) .encodeX("Acceleration", Quantitative, bin=Bin()) .encodeY("Horsepower", Quantitative, AggOps.Mean, enableBin=false) .encodeColor(field="Cylinders", dataType=Nominal) .show