Example Gallery

Autocorrelation Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

plot_autocorr(data; var_names=["tau", "mu"])
gcf()

Bayes Factor Plot

using ArviZ, ArviZPythonPlots

use_style("arviz-darkgrid")

idata = from_namedtuple((a = 1 .+ randn(5_000) ./ 2,), prior=(a = randn(5_000),))
plot_bf(idata; var_name="a", ref_val=0)
gcf()

See plot_bf

Bayesian P-Value Posterior Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

plot_bpv(data)
gcf()

See plot_bpv

Bayesian P-Value with Median T Statistic Posterior Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

plot_bpv(data; kind="t_stat", t_stat="0.5")
gcf()

See plot_bpv

Compare Plot

using ArviZ, ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

model_compare = compare(
(
),
)
plot_compare(model_compare; figsize=(12, 4))
gcf()

Density Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

plot_density(
[centered_data, non_centered_data];
data_labels=["Centered", "Non Centered"],
var_names=["theta"],
)
gcf()

See plot_density

Dist Plot

using ArviZPythonPlots, Distributions, Random

Random.seed!(308)

use_style("arviz-darkgrid")

a = rand(Poisson(4), 1000)
b = rand(Normal(0, 1), 1000)
_, ax = subplots(1, 2; figsize=(10, 4))
plot_dist(a; color="C1", label="Poisson", ax=ax[0])
plot_dist(b; color="C2", label="Gaussian", ax=ax[1])
gcf()

See plot_dist

Dot Plot

using ArviZPythonPlots

use_style("arviz-darkgrid")

data = randn(1000)
plot_dot(data; dotcolor="C1", point_interval=true)
title("Gaussian Distribution")
gcf()

See plot_dot

ECDF Plot

using ArviZPythonPlots, Distributions

use_style("arviz-darkgrid")

sample = randn(1_000)
dist = Normal()
plot_ecdf(sample; cdf=x -> cdf(dist, x), confidence_bands=true)
gcf()

See plot_ecdf

ELPD Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

plot_elpd(Dict("Centered eight" => d1, "Non centered eight" => d2); xlabels=true)
gcf()

See plot_elpd

Energy Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

plot_energy(data; figsize=(12, 8))
gcf()

See plot_energy

ESS Evolution Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

plot_ess(idata; var_names=["b"], kind="evolution")
gcf()

See plot_ess

ESS Local Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

plot_ess(idata; var_names=["mu"], kind="local", marker="_", ms=20, mew=2, rug=true)
gcf()

See plot_ess

ESS Quantile Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

plot_ess(idata; var_names=["sigma"], kind="quantile", color="C4")
gcf()

See plot_ess

Forest Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

plot_forest(
[centered_data, non_centered_data];
model_names=["Centered", "Non Centered"],
var_names=["mu"],
)
title("Estimated theta for eight schools model")
gcf()

See plot_forest

Ridge Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

plot_forest(
rugby_data;
kind="ridgeplot",
var_names=["defs"],
linewidth=4,
combined=true,
ridgeplot_overlap=1.5,
colors="blue",
figsize=(9, 4),
)
title("Relative defensive strength\nof Six Nation rugby teams")
gcf()

See plot_forest

Plot HDI

using Random
using ArviZPythonPlots

Random.seed!(308)

use_style("arviz-darkgrid")

x_data = randn(100)
y_data = 2 .+ x_data .* 0.5
y_data_rep = 0.5 .* randn(200, 100) .+ transpose(y_data)

plot(x_data, y_data; color="C6")
plot_hdi(x_data, y_data_rep; color="k", plot_kwargs=Dict("ls" => "--"))
gcf()

See plot_hdi

Joint Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

plot_pair(
data;
var_names=["theta"],
coords=Dict("school" => ["Choate", "Phillips Andover"]),
kind="hexbin",
marginals=true,
figsize=(10, 10),
)
gcf()

See plot_pair

KDE Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

## Combine different posterior draws from different chains
obs = data.posterior_predictive.obs
size_obs = size(obs)
y_hat = reshape(obs, prod(size_obs[1:2]), size_obs[3:end]...)

plot_kde(
y_hat;
label="Estimated Effect\n of SAT Prep",
rug=true,
plot_kwargs=Dict("linewidth" => 2, "color" => "black"),
rug_kwargs=Dict("color" => "black"),
)
gcf()

See plot_kde

2d KDE

using Random
using ArviZPythonPlots

Random.seed!(308)

use_style("arviz-darkgrid")

plot_kde(rand(100), rand(100))
gcf()

See plot_kde

KDE Quantiles Plot

using Random
using Distributions
using ArviZPythonPlots

Random.seed!(308)

use_style("arviz-darkgrid")

dist = rand(Beta(rand(Uniform(0.5, 10)), 5), 1000)
plot_kde(dist; quantiles=[0.25, 0.5, 0.75])
gcf()

See plot_kde

Pareto Shape Plot

using ArviZ, ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

loo_data = loo(idata)
plot_khat(loo_data; show_bins=true)
gcf()

See loo, plot_khat

LOO-PIT ECDF Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

plot_loo_pit(idata; y="y", ecdf=true, color="maroon")
gcf()

LOO-PIT Overlay Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

plot_loo_pit(; idata, y="obs", color="indigo")
gcf()

Quantile Monte Carlo Standard Error Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

plot_mcse(data; var_names=["tau", "mu"], rug=true, extra_methods=true)
gcf()

See plot_mcse

Quantile MCSE Errobar Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

plot_mcse(data; var_names=["sigma_a"], color="C4", errorbar=true)
gcf()

See plot_mcse

Pair Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

coords = Dict("school" => ["Choate", "Deerfield"])
plot_pair(
centered; var_names=["theta", "mu", "tau"], coords, divergences=true, textsize=22
)
gcf()

See plot_pair

Hexbin Pair Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

coords = Dict("school" => ["Choate", "Deerfield"])
plot_pair(
centered;
var_names=["theta", "mu", "tau"],
kind="hexbin",
coords,
colorbar=true,
divergences=true,
)
gcf()

See plot_pair

KDE Pair Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

coords = Dict("school" => ["Choate", "Deerfield"])
plot_pair(
centered;
var_names=["theta", "mu", "tau"],
kind="kde",
coords,
divergences=true,
textsize=22,
)
gcf()

See plot_pair

Point Estimate Pair Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

coords = Dict("school" => ["Choate", "Deerfield"])
plot_pair(
centered;
var_names=["mu", "theta"],
kind=["scatter", "kde"],
kde_kwargs=Dict("fill_last" => false),
marginals=true,
coords,
point_estimate="median",
figsize=(10, 8),
)
gcf()

See plot_pair

Parallel Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

ax = plot_parallel(data; var_names=["theta", "tau", "mu"])
ax.set_xticklabels(ax.get_xticklabels(); rotation=70)
draw()
gcf()

Posterior Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

coords = Dict("school" => ["Choate"])
plot_posterior(data; var_names=["mu", "theta"], coords, rope=(-1, 1))
gcf()

Posterior Predictive Check Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

plot_ppc(data; data_pairs=Dict("obs" => "obs"), alpha=0.03, figsize=(12, 6), textsize=14)
gcf()

See plot_ppc

Posterior Predictive Check Cumulative Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

plot_ppc(data; alpha=0.3, kind="cumulative", figsize=(12, 6), textsize=14)
gcf()

See plot_ppc

Rank Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

plot_rank(data; var_names=["tau", "mu"])
gcf()

See plot_rank

Regression Plot

using ArviZ, ArviZPythonPlots, ArviZExampleData, DimensionalData

use_style("arviz-darkgrid")

x = range(0, 1; length=100)
posterior = data.posterior
constant_data = convert_to_dataset((; x); default_dims=())
posterior = merge(posterior, (; y_model))
data = merge(data, InferenceData(; posterior, constant_data))
plot_lm("y"; idata=data, x="x", y_model="y_model")
gcf()

See plot_lm

Separation Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

plot_separation(data; y="outcome", y_hat="outcome", figsize=(8, 1))
gcf()

Trace Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

plot_trace(data; var_names=["tau", "mu"])
gcf()

See plot_trace

Violin Plot

using ArviZPythonPlots, ArviZExampleData

use_style("arviz-darkgrid")

plot_violin(data; var_names=["mu", "tau"])
gcf()

See plot_violin

Styles

using ArviZPythonPlots, Distributions, PythonCall

x = range(0, 1; length=100)
dist = pdf.(Beta(2, 5), x)

style_list = [
"default",
["default", "arviz-colors"],
"arviz-darkgrid",
"arviz-whitegrid",
"arviz-white",
"arviz-grayscale",
["arviz-white", "arviz-redish"],
["arviz-white", "arviz-bluish"],
["arviz-white", "arviz-orangish"],
["arviz-white", "arviz-brownish"],
["arviz-white", "arviz-purplish"],
["arviz-white", "arviz-cyanish"],
["arviz-white", "arviz-greenish"],
["arviz-white", "arviz-royish"],
["arviz-white", "arviz-viridish"],
["arviz-white", "arviz-plasmish"],
"arviz-doc",
"arviz-docgrid",
]

fig = figure(; figsize=(20, 10))
for (idx, style) in enumerate(style_list)
pywith(pyplot.style.context(style; after_reset=true)) do _
ax = fig.add_subplot(5, 4, idx; label=idx)
colors = pyplot.rcParams["axes.prop_cycle"].by_key()["color"]
for i in 0:(length(colors) - 1)
ax.plot(x, dist .- i, "C$i"; label="C$i")
end
ax.set_title(style)
ax.set_xlabel("x")