Simple Charts

Simple Charts

Simple Bar Chart

using VegaLite, DataFrames

data = DataFrame(
    a=["A","B","C","D","E","F","G","H","I"],
    b=[28,55,43,91,81,53,19,87,52]
)

data |> @vlplot(:bar, x=:a, y=:b)
ABCDEFGHIa020406080100b

Simple Heatmap

using VegaLite, DataFrames

x = [j for i in -5:4, j in -5:4]
y = [i for i in -5:4, j in -5:4]
z = x.^2 .+ y.^2
data = DataFrame(x=vec(x'),y=vec(y'),z=vec(z'))

data |> @vlplot(:rect, x="x:o", y="y:o", color=:z)
01020304050z-5-4-3-2-101234x-5-4-3-2-101234y

Simple Histogram

using VegaLite, VegaDatasets

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

Simple Line Chart

using VegaLite, DataFrames

x = 0:100
data = DataFrame(x=x,sin=sin.(x./5))

data |> @vlplot(:line, x=:x, y={:sin, title="sin(x)"})
020406080100x-1.0-0.50.00.51.0sin(x)

Simple Scatter Plot

using VegaLite, VegaDatasets

dataset("iris") |>
@vlplot(:point, x=:petalWidth, y=:petalLength, color=:species)
setosaversicolorvirginicaspecies0.00.51.01.52.02.5petalWidth01234567petalLength

TODO Add interactivity

Simple Stacked Area Chart

using VegaLite, VegaDatasets

dataset("unemployment-across-industries") |>
@vlplot(:area, x="date:t", y=:count, color=:series)
AgricultureBusiness servicesConstructionEducation and Heal…FinanceGovernmentInformationLeisure and hospit…ManufacturingMining and Extract…OtherSelf-employedTransportation and…Wholesale and Reta…series20022004200620082010date05,00010,00015,000count

Strip Plot

using VegaLite, VegaDatasets

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