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_Gallon050100150200Horsepower01020304050Miles_per_GallonEuropeJapanUSAOrigin

Marginal Histograms

using VegaLite, VegaDatasets

p_hist1 = @vlplot(
    :bar,
    height=60,
    x={:IMDB_Rating, bin=true, axis=nothing},
    y={"count()", scale={domain=[0,1000]}, title=nothing}
)

p_main = @vlplot(
    :rect,
    x={"IMDB_Rating:q", bin=true},
    y={"Rotten_Tomatoes_Rating:q", bin=true},
    color="count()"
)

p_hist2 = @vlplot(
    :bar,
    width=60,
    y={"Rotten_Tomatoes_Rating:q", bin=true, axis=nothing},
    x={"count()", scale={domain=[0,1000]}, title=nothing}
)

dataset("movies") |>
@vlplot(spacing=15, founds=:flush, config={view={stroke=:transparent}}) + [p_hist1; @vlplot(spacing=15, bounds=:flush) + [p_main p_hist2]]
05001,0001.02.03.04.05.06.07.08.09.010.0IMDB_Rating (binned)0102030405060708090100Rotten_Tomatoes_Rating (binned)05001,00050100150Count of Records