Error Bars & Error Bands

Error Bars & Error Bands

Error Bars showing Confidence Interval

using VegaLite, VegaDatasets

dataset("barley") |>
@vlplot(y="variety:o") +
@vlplot(
    mark={
        :point,
        filled=true
    },
    x={
        "mean(yield)",
        scale={zero=false},
        title="Barley Yield"
    },
    color={value=:black}
) +
@vlplot(
    mark={
        :errorbar,
        extent=:ci
     },
     x={"yield:q", title="Barley Yield"}
)
2530354045Barley YieldGlabronManchuriaNo. 457No. 462No. 475PeatlandSvansotaTrebiVelvetWisconsin No. 38variety

Error Bars showing Standard Deviation

using VegaLite, VegaDatasets

dataset("barley") |>
@vlplot(
    y="variety:o"
) +
@vlplot(
    mark={
        :point,
        filled=true
    },
    x={
        "mean(yield)",
        scale={zero=false},
        title="Barley Yield"
    },
    color={value=:black}
) +
@vlplot(
    mark={:rule, extend=:stdev},
    x={:yield, title="Barley Yield"}
)
10203040506070Barley YieldGlabronManchuriaNo. 457No. 462No. 475PeatlandSvansotaTrebiVelvetWisconsin No. 38variety

Line Chart with Confidence Interval Band

using VegaLite, VegaDatasets

dataset("cars") |>
@vlplot(x="year(Year)") +
@vlplot(
    mark={:errorband, extent=:ci},
    y={
        "Miles_per_Gallon:q",
        title="Mean of Miles per Gallon (95% CIs)"
    }
) +
@vlplot(
    :line,
    y="mean(Miles_per_Gallon)"
)
1970197219741976197819801982Year (year)010203040Mean of Miles per Gallon (95% CIs)

Scatterplot with Mean and Standard Deviation Overlay

using VegaLite, VegaDatasets

dataset("cars") |>
@vlplot() +
@vlplot(
    :point,
    x=:Horsepower,
    y=:Miles_per_Gallon
) +
@vlplot(:rule,y={"mean(Miles_per_Gallon)") +
@vlplot(
    mark={:errorband, extent=:stdev, opacity=0.2},
    y={"Miles_per_Gallon", title="Miles per Gallon"}
)