Histograms, Density Plots, and Dot Plots

Histogram

using VegaLite, VegaDatasets

dataset("movies") |>
@vlplot(:bar, x={:IMDB_Rating, bin=true}, y="count()")
1.02.03.04.05.06.07.08.09.010.0IMDB_Rating (binned)02004006008001,000Count of Records

Histogram (from Binned Data)

using VegaLite, DataFrames

data=DataFrame(
    bin_start=[8,10,12,14,16,18,20,22],
    bin_end=[10,12,14,16,18,20,22,24],
    count=[7,29,71,127,94,54,17,5]
)
data |> @vlplot(
    :bar,
    x={:bin_start, bin={binned=true,step=2}},
    x2=:bin_end,
    y=:count
)
81012141618202224bin_start, bin_end020406080100120count

Log-scaled Histogram

using VegaLite, DataFrames

data=DataFrame(
    x=[0.01,0.1,1,1,1,1,10,10,100,500,800]
)

data |> @vlplot(
    :bar,
    transform=[
        {calculate="log(datum.x)/log(10)", as="log_x"},
        {field="log_x",bin=true,as="bin_log_x"},
        {calculate="pow(10, datum.bin_log_x)", as="x1"},
        {calculate="pow(10, datum.bin_log_x_end)", as="x2"}
    ],
    x={"x1:q", scale={type="log",base=10},axis={tickCount=5}},
    x2=:x2,
    y={aggregate="count",type="quantitative"}
)
0.0010.010.11101001,00010,000x1, x201234Count of Records

Density Plot

using VegaLite, VegaDatasets

dataset("movies") |>
@vlplot(
    width=400,
    height=100,
    :area,
    transform=[
        {density="IMDB_Rating",bandwidth=0.3}
    ],
    x={"value:q", title="IMDB Rating"},
    y="density:q"
)
12345678910IMDB Rating0.00.10.20.3density

Stacked Density Estimates

using VegaLite, VegaDatasets

dataset("movies") |>
@vlplot(
    width=400,
    height=100,
    :area,
    transform=[
        {density="IMDB_Rating",bandwidth=0.3,groupby=["Major_Genre"],extent=[0, 10],counts=true,steps=50}
    ],
    x={"value:q", title="IMDB Rating"},
    y= {"density:q",stack=true},
    color={"Major_Genre:n",scale={scheme=:category20}}
)
012345678910IMDB Rating05001,000densitynullActionAdventureBlack ComedyComedyConcert/PerformanceDocumentaryDramaHorrorMusicalRomantic ComedyThriller/SuspenseWesternMajor_Genre

2D Histogram Scatterplot

using VegaLite, VegaDatasets

dataset("movies") |>
@vlplot(
    :circle,
    x={:IMDB_Rating, bin={maxbins=10}},
    y={:Rotten_Tomatoes_Rating, bin={maxbins=10}},
    size="count()"
)
1.02.03.04.05.06.07.08.09.010.0IMDB_Rating (binned)0102030405060708090100Rotten_Tomatoes_Rating (binned)50100150Count of Records

2D Histogram Heatmap

using VegaLite, VegaDatasets

dataset("movies") |>
@vlplot(
    :rect,
    width=300, height=200,
    x={:IMDB_Rating, bin={maxbins=60}},
    y={:Rotten_Tomatoes_Rating, bin={maxbins=40}},
    color="count()",
    config={
        range={
            heatmap={
                scheme="greenblue"
            }
        },
        view={
            stroke="transparent"
        }
    }
)
5101520Count of Records1.21.41.61.82.02.22.42.62.83.03.23.43.63.84.04.24.44.64.85.05.25.45.65.86.06.26.46.66.87.07.27.47.67.88.08.28.48.68.89.09.2IMDB_Rating (binned)05101520253035404550556065707580859095100Rotten_Tomatoes_Rating (binned)

Cumulative Frequency Distribution

using VegaLite, VegaDatasets

dataset("movies") |>
@vlplot(
    :area,
    transform=[{
        sort=[{field=:IMDB_Rating}],
        window=[{field=:count,op="count",as="cumulative_count"}],
        frame=[nothing,0]
    }],
    x="IMDB_Rating:q",
    y="cumulative_count:q"
)
246810IMDB_Rating05001,0001,5002,0002,5003,0003,500cumulative_count

Layered Histogram and Cumulative Histogram

using VegaLite, VegaDatasets

dataset("movies") |>
@vlplot(
    transform=[
        {bin=true,field=:IMDB_Rating,as="bin_IMDB_Rating"},
        {
            aggregate=[{op=:count,as="count"}],
            groupby=["bin_IMDB_Rating", "bin_IMDB_Rating_end"]
        },
        {filter="datum.bin_IMDB_Rating !== null"},
        {
            sort=[{field=:bin_IMDB_Rating}],
            window=[{field=:count,op="sum",as="cumulative_count"}],
            frame=[nothing,0]
        }
    ],
    x={"bin_IMDB_Rating:q",scale={zero=false},title="IMDB Rating"},
    x2=:bin_IMDB_Rating_end
) +
@vlplot(
    :bar,
    y="cumulative_count:q"
) +
@vlplot(
    mark={:bar,color=:yellow,opacity=0.5},
    y="count:q"
)
246810IMDB Rating01,0002,0003,000cumulative_count, count

Violin Plot

using VegaLite, VegaDatasets

dataset("cars") |> @vlplot(
    mark={:area, orient="horizontal"},
    transform=[
        {density="Miles_per_Gallon", groupby=["Origin"], extent=[5, 50],
        as=["Miles_per_Gallon", "density"]}
    ],
    y="Miles_per_Gallon:q",
    x= {"density:q", stack="center", impute=nothing, title=nothing,
        axis={labels=false, values=[0], grid=false, ticks=true}},
    column={"Origin:n", header={titleOrient="bottom", labelOrient="bottom",
            labelPadding=0}},
    color = "Origin:n",
    width=70,
    spacing=0,
    config={view={stroke=nothing}}
)
Origin1020304050Miles_per_GallonEuropeJapanUSAEuropeJapanUSAOrigin

Wilkinson Dot Plot

using VegaLite, DataFrames

data=DataFrame(data=[
    1,1,1,1,1,1,1,1,1,1,
    2,2,2,
    3,3,
    4,4,4,4,4,4
])

data |> @vlplot(
    height=100,
    mark={:circle,opacity=1},
    transform=[{
        window=[{op=:rank,as="id"}],
        groupby= [:data]
    }],
    x="data:o",
    y={"id:o",axis=nothing,sort=:descending}
)
1234data

Isotype Dot Plot

using VegaLite, DataFrames

df=DataFrame(
    country=["Great,Britain","Great,Britain","Great,Britain","Great,Britain","Great,Britain","Great,Britain","Great,Britain","Great,Britain","Great,Britain","Great,Britain","Great,Britain","Great,Britain","Great,Britain","Great,Britain","Great,Britain","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States"],
    animal=["cattle","cattle","cattle","pigs","pigs","sheep","sheep","sheep","sheep","sheep","sheep","sheep","sheep","sheep","sheep","cattle","cattle","cattle","cattle","cattle","cattle","cattle","cattle","cattle","pigs","pigs","pigs","pigs","pigs","pigs","sheep","sheep","sheep","sheep","sheep","sheep","sheep"],
    col=[3,2,1,2,1,10,9,8,7,6,5,4,3,2,1,9,8,7,6,5,4,3,2,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 -0.7c0.1 -0.2 -0.1 -1 -0.2 -1.1c-0.1 -0.2 -0.2 -0.8 -0.2 -0.8c0 0 -0.1 -0.5 0.4 -0.8z"

df |> @vlplot(
    config={view={stroke=nothing}},
    height=200,
    width=800,
    mark={:point, filled=true},
    x={"col:o", axis=nothing},
    y={"animal:o", axis=nothing},
    row={"country:n", header={title=nothing}},
    shape={
        "animal:n",
        scale={
            domain=[ "person", "cattle", "pigs", "sheep" ],
            range=[ personSVGPath, cattleSVGPath, pigsSVGPath, sheepSVGPath ]
        },
        legend=nothing
    },
    color={
        "animal:n",
        legend=nothing,
        scale={
            domain=[ "person", "cattle", "pigs", "sheep" ],
            range=[
                "rgb(162,160,152)",
                "rgb(194,81,64)",
                "rgb(93,93,93)",
                "rgb(91,131,149)"
            ]
        }
    },
    opacity={ value=1 },
    size={ value=200 }
)
Great,BritainUnited,States

Isotype Dot Plot with Emoji

using VegaLite, DataFrames

df=DataFrame(
    country=["Great,Britain","Great,Britain","Great,Britain","Great,Britain","Great,Britain","Great,Britain","Great,Britain","Great,Britain","Great,Britain","Great,Britain","Great,Britain","Great,Britain","Great,Britain","Great,Britain","Great,Britain","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States","United,States"],
    animal=["cattle","cattle","cattle","pigs","pigs","sheep","sheep","sheep","sheep","sheep","sheep","sheep","sheep","sheep","sheep","cattle","cattle","cattle","cattle","cattle","cattle","cattle","cattle","cattle","pigs","pigs","pigs","pigs","pigs","pigs","sheep","sheep","sheep","sheep","sheep","sheep","sheep"],
    col=[3,2,1,2,1,10,9,8,7,6,5,4,3,2,1,9,8,7,6,5,4,3,2,1,6,5,4,3,2,1,7,6,5,4,3,2,1]
)
personSVGPath="M1.7 -1.7h-0.8c0.3 -0.2 0.6 -0.5 0.6 -0.9c0 -0.6 -0.4 -1 -1 -1c-0.6 0 -1 0.4 -1 1c0 0.4 0.2 0.7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
            calculate="{'cattle': '🐄', 'pigs': '🐖', 'sheep': '🐏'}[datum.animal]",
            as=:emoji
        },
        {window=[{op=:rank, as=:rank}], groupby=[:country, :animal]}
    ],
    mark={:text, baseline=:middle},
    x={"rank:o", axis=nothing},
    y={"animal:n", axis=nothing, sort=nothing},
    row={"country:n", header={title=nothing}},
    text="emoji:n",
    size={ value=65 }
)
Great,BritainUnited,States🐄🐄🐄🐖🐖🐏🐏🐏🐏🐏🐏🐏🐏🐏🐏🐄🐄🐄🐄🐄🐄🐄🐄🐄🐖🐖🐖🐖🐖🐖🐏🐏🐏🐏🐏🐏🐏