Repeat & Concatenation

Repeat and layer to show different weather measures

using VegaLite, VegaDatasets

dataset("weather.csv") |>
@vlplot(repeat={column=[:temp_max,:precipitation,:wind]}) +
(
    @vlplot() +
    @vlplot(
        :line,
        y={field={repeat=:column},aggregate=:mean,type=:quantitative},
        x="month(date):o",
        detail="year(date)",
        color=:location,
        opacity={value=0.2}
    ) +
    @vlplot(
        :line,
        y={field={repeat=:column},aggregate=:mean,type=:quantitative},
        x="month(date):o",
        color=:location
    )
)
JanFebMarAprMayJunJulAugSepOctNovDecdate (month)05101520253035Mean of temp_maxJanFebMarAprMayJunJulAugSepOctNovDecdate (month)0246810Mean of precipitationJanFebMarAprMayJunJulAugSepOctNovDecdate (month)0123456Mean of windNew YorkSeattlelocation

Vertically concatenated charts that show precipitation in Seattle

using VegaLite, VegaDatasets

dataset("weather.csv") |>
@vlplot(transform=[{filter="datum.location === 'Seattle'"}]) +
[
    @vlplot(:bar,x="month(date):o",y="mean(precipitation)");
    @vlplot(:point,x={:temp_min, bin=true}, y={:temp_max, bin=true}, size="count()")
]
JanFebMarAprMayJunJulAugSepOctNovDecdate (month)012345Mean of precipitation−10−505101520temp_min (binned)−50510152025303540temp_max (binned)50100150200250Count of Records

Horizontally repeated charts

using VegaLite, VegaDatasets

dataset("cars") |>
@vlplot(repeat={column=[:Horsepower, :Miles_per_Gallon, :Acceleration]}) +
@vlplot(
    :bar,
    x={field={repeat=:column},bin=true,type=:quantitative},
    y="count()",
    color=:Origin
)
406080100120140160180200220240Horsepower (binned)020406080100120Count of Records5101520253035404550Miles_per_Gallon (binned)020406080100Count of Records8101214161820222426Acceleration (binned)020406080100120Count of RecordsEuropeJapanUSAOrigin

Interactive Scatterplot Matrix

using VegaLite, VegaDatasets

dataset("cars") |>
@vlplot(
    repeat={
        row=[:Horsepower, :Acceleration, :Miles_per_Gallon],
        column=[:Miles_per_Gallon, :Acceleration, :Horsepower]
    }
) +
@vlplot(
    :point,
    selection={
        brush={
            type=:interval,
            resolve=:union,
            on="[mousedown[event.shiftKey], window:mouseup] > window:mousemove!",
            translate="[mousedown[event.shiftKey], window:mouseup] > window:mousemove!",
            zoom="wheel![event.shiftKey]"
        },
        grid={
            type=:interval,
            resolve=:global,
            bind=:scales,
            translate="[mousedown[!event.shiftKey], window:mouseup] > window:mousemove!",
            zoom="wheel![!event.shiftKey]"
        }
    },
    x={field={repeat=:column}, type=:quantitative},
    y={field={repeat=:row}, type=:quantitative},
    color={
        condition={
            selection=:brush,
            field=:Origin,
            type=:nominal
        },
        value=:grey
    }
)
01020304050Miles_per_Gallon050100150200Horsepower0510152025Acceleration050100150200Horsepower050100150200Horsepower050100150200Horsepower01020304050Miles_per_Gallon0510152025Acceleration0510152025Acceleration0510152025Acceleration050100150200Horsepower0510152025Acceleration01020304050Miles_per_Gallon01020304050Miles_per_Gallon0510152025Acceleration01020304050Miles_per_Gallon