Scatter & Strip Plots

Scatterplot

using VegaLite, VegaDatasets

dataset("cars") |>
@vlplot(:point, x=:Horsepower, y=:Miles_per_Gallon)
050100150200Horsepower01020304050Miles_per_Gallon

Dot Plot

using VegaLite, VegaDatasets

dataset("seattle-weather") |>
@vlplot(:tick, x=:precipitation)
0102030405060precipitation

Strip Plot

using VegaLite, VegaDatasets

dataset("cars") |>
@vlplot(:tick, x=:Horsepower, y="Cylinders:o")
050100150200Horsepower34568Cylinders

Colored Scatterplot

using VegaLite, VegaDatasets

dataset("cars") |>
@vlplot(:point, x=:Horsepower, y=:Miles_per_Gallon, color=:Origin, shape=:Origin)
050100150200Horsepower01020304050Miles_per_GallonEuropeJapanUSAOrigin

Binned 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

Bubble Plot

using VegaLite, VegaDatasets

dataset("cars") |>
@vlplot(:point, x=:Horsepower, y=:Miles_per_Gallon, size=:Acceleration)
050100150200Horsepower01020304050Miles_per_Gallon5101520Acceleration

Scatterplot with NA Values in Grey

using VegaLite, VegaDatasets

dataset("movies") |>
@vlplot(
    :point,
    x=:IMDB_Rating,
    y=:Rotten_Tomatoes_Rating,
    color={
        condition={
            test="datum.IMDB_Rating === null || datum.Rotten_Tomatoes_Rating === null",
            value="#aaa"
        }
    },
    config={invalidValues=nothing}
)
0246810IMDB_Rating020406080100Rotten_Tomatoes_Rating

Scatterplot with Filled Circles

using VegaLite, VegaDatasets

dataset("cars") |>
@vlplot(:circle, x=:Horsepower, y=:Miles_per_Gallon)
050100150200Horsepower01020304050Miles_per_Gallon

Bubble Plot (Gapminder)

using VegaLite, VegaDatasets

dataset("gapminder-health-income") |>
@vlplot(
    :circle,
    width=500,height=300,
    selection={
        view={type=:interval, bind=:scales}
    },
    y={:health, scale={zero=false}, axis={minExtent=30}},
    x={:income, scale={type=:log}},
    size=:population,
    color={value="#000"}
)
1002001,0002,00010,00020,000100,000200,0001,000,000income455055606570758085health200,000,000400,000,000600,000,000800,000,0001,000,000,0001,200,000,000population

Bubble Plot (Natural Disasters)

using VegaLite, VegaDatasets

dataset("disasters") |>
@vlplot(
    width=600,height=400,
    transform=[
        {filter="datum.Entity !== 'All natural disasters'"}
    ],
    mark={
        :circle,
        opacity=0.8,
        stroke=:black,
        strokeWidth=1
    },
    x={"Year:o", axis={labelAngle=0}},
    y={:Entity, axis={title=""}},
    size={
        :Deaths,
        legend={title="Annual Global Deaths"},
        scale={range=[0,5000]}
    },
    color={:Entity, legend=nothing}
)
190019011902190319051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017YearDroughtEarthquakeEpidemicExtreme temperatureExtreme weatherFloodLandslideMass movement (dry)Volcanic activityWildfire1,000,0002,000,0003,000,000Annual Global Deaths

Scatter Plot with Text Marks

using VegaLite, VegaDatasets

dataset("cars") |>
@vlplot(
    :text,
    transform=[
        {
            calculate="datum.Origin[0]",
            as="OriginInitial"
        }
    ],
    x=:Horsepower,
    y=:Miles_per_Gallon,
    color=:Origin,
    text="OriginInitial:n"
)
050100150200Horsepower01020304050Miles_per_GallonUUUUUUUUUUUUUUJUUUJEEEEEUUUUUJUJUUUUUUUUUUUUUUUUUEEEJJEUJUEUUUUUUUUUUUJUUUUEEEEUJJUJUUUUUUUUUUUUUUUUUEUUUUUJUJJUUEUUEEEEUEJUUUUJUJUUUUUUUUUEEEJJUEEJJEUUUUUUUUUUUUUUUJUUUJEJUEUEEEEJEEUUEUUUUUUUUUUEJUUUUEJJUEUEJEUUUUJUEUJUUUUUUUUUUUUEUJUUUJEJEJEUJJJUUUUUUUUUUUUUUUUUUJJUJUUJEEEEEJUUUUUUUUUUUUUEJUUEUEUUUJEUUUUEJUJUUUUEJJJJJUJEEEEJJEJJEJUUUUUJUJJJJJUUUEJJJJEEJJUUUUUUUUUUUEJJUUJJJJJJUUUUJUUUEUUUEuropeJapanUSAOrigin

Image-based Scatter Plot

using VegaLite, VegaDatasets, DataFrames
data=DataFrame(
    x=[0.5,1.5,2.5],
    y=[0.5,1.5,2.5],
    #use the following code to reproduce on a local REPL:
    #   Construct the URL to the local example images with absolute paths:
    #      file:///C:/Users/username/.julia/packages/VegaDatasets/9E5lE/src/../data/data/ffox.png
    #   img=[
    #      "file:///"*replace(joinpath(joinpath(dirname(pathof(VegaDatasets)),"..","data"),"data","ffox.png"),"\\" => "/"),
    #      "file:///"*replace(joinpath(joinpath(dirname(pathof(VegaDatasets)),"..","data"),"data","gimp.png"),"\\" => "/"),
    #      "file:///"*replace(joinpath(joinpath(dirname(pathof(VegaDatasets)),"..","data"),"data","7zip.png"),"\\" => "/")
    #   ]
    img=[
        "../../assets/images/ffox.png",
        "../../assets/images/gimp.png",
        "../../assets/images/7zip.png"
    ]
)
data |> @vlplot(
    mark={:image,width=50,height=50},
    x="x:q",
    y="y:q",
    url={field=:img}
)
0.00.51.01.52.02.5x0.00.51.01.52.02.5y