Skip to content

Commit

Permalink
add bounds to gallery images (#539)
Browse files Browse the repository at this point in the history
* add bounds to gallery images

* remove comment

* adjust figsize

* revert init_val skewt
  • Loading branch information
aloctavodia authored Sep 24, 2024
1 parent d839f9d commit bb7ef2b
Show file tree
Hide file tree
Showing 50 changed files with 77 additions and 3 deletions.
Binary file modified docs/examples/img/AsymmetricLaplace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Bernoulli.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Beta.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/BetaBinomial.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/BetaScaled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Binomial.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Categorical.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Cauchy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Censored.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/ChiSquared.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/DiscreteUniform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/DiscreteWeibull.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/ExGaussian.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Exponential.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Gamma.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Geometric.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Gumbel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/HalfCauchy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/HalfNormal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/HalfStudentT.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Hurdle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/HyperGeometric.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/InverseGamma.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Kumaraswamy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/Laplace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/examples/img/LogLogistic.png
Binary file modified docs/examples/img/LogNormal.png
Binary file modified docs/examples/img/Logistic.png
Binary file modified docs/examples/img/LogitNormal.png
Binary file modified docs/examples/img/Moyal.png
Binary file modified docs/examples/img/NegativeBinomial.png
Binary file modified docs/examples/img/Normal.png
Binary file modified docs/examples/img/Pareto.png
Binary file modified docs/examples/img/Poisson.png
Binary file modified docs/examples/img/Rice.png
Binary file modified docs/examples/img/SkewNormal.png
Binary file modified docs/examples/img/SkewStudentT.png
Binary file modified docs/examples/img/StudentT.png
Binary file modified docs/examples/img/Triangular.png
Binary file modified docs/examples/img/Truncated.png
Binary file modified docs/examples/img/TruncatedNormal.png
Binary file modified docs/examples/img/Uniform.png
Binary file modified docs/examples/img/VonMises.png
Binary file modified docs/examples/img/Wald.png
Binary file modified docs/examples/img/Weibull.png
Binary file modified docs/examples/img/ZeroInflatedBinomial.png
Binary file modified docs/examples/img/ZeroInflatedNegativeBinomial.png
Binary file modified docs/examples/img/ZeroInflatedPoisson.png
78 changes: 76 additions & 2 deletions docs/get_cover_gallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
rng = np.random.default_rng(247)

init_vals["Hurdle"] = None
init_vals["SkewStudentT"] = {"mu": 0.0, "sigma": 1, "a": 2.5, "b": 1.5}
for name, params in init_vals.items():
color = f"C{rng.integers(0, 4)}"
_, ax = plt.subplots(figsize=(6, 4))
_, ax = plt.subplots(figsize=(3.5, 2.3))
dist = getattr(distributions, name)
if name in ["Truncated", "Censored"]:
dist(Gamma(mu=2, sigma=1), -np.inf, 2).plot_pdf(legend=False, ax=ax, color=color)
Expand Down Expand Up @@ -42,5 +43,78 @@

ax.set_xticks([])
ax.set_yticks([])
ax.spines[["left", "bottom"]].set_visible(False)
ax.spines[["left"]].set_visible(False)

if name in ["Categorical"]:
ax.set_xticks([0, 1, 2], labels=["♣", "♥", "♦"])
else:
if name in ["BetaScaled", "Truncated", "Censored", "Pareto"]:
l_b, u_b = (-np.inf, np.inf)
elif name == "Hurdle":
l_b, u_b = (0, np.inf)
else:
l_b, u_b = dist().support

if l_b == -np.inf:
l_b = None
if u_b == np.inf:
u_b = None

pos = ax.get_ylim()[0]

# The boundaries depended on the parameterization
if name in [
"BetaScaled",
"TruncatedNormal",
"Triangular",
"Uniform",
"Binomial",
"BetaBinomial",
"DiscreteUniform",
"HyperGeometric",
"Censored",
"Hurdle",
"Truncated",
]:
marker_0 = marker_1 = "*"
elif name == "Pareto":
marker_0 = "*"
marker_1 = ">"
else:
marker_0 = "<"
marker_1 = ">"

if l_b is None:
ax.plot(
0,
pos,
color="k",
marker=marker_0,
transform=ax.get_yaxis_transform(),
clip_on=False,
zorder=3,
)
if u_b is None:
ax.plot(
1,
pos,
color="k",
marker=marker_1,
transform=ax.get_yaxis_transform(),
clip_on=False,
zorder=3,
)

if name == "VonMises":
ax.set_xticks([l_b, u_b], labels=["$-\pi$", "$\pi$"])

if l_b is not None and u_b is not None:
ax.set_xticks([l_b, u_b])
elif l_b is not None and u_b is None:
ax.set_xticks([l_b])
elif l_b is None and u_b is not None:
ax.set_xticks([u_b])

ax.spines["bottom"].set_position(("data", pos))

plt.savefig(f"examples/img/{name}.png")
2 changes: 1 addition & 1 deletion preliz/internal/distribution_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def process_extra(input_string):
"Pareto": {"alpha": 5, "m": 2.0},
"Rice": {"nu": 2.0, "sigma": 1.0},
"SkewNormal": {"mu": 0.0, "sigma": 1, "alpha": 6.0},
"SkewStudentT": {"mu": 0.0, "sigma": 1, "a": 2.0, "b": 2.0},
"SkewStudentT": {"mu": 0.0, "sigma": 1, "a": 2, "b": 2},
"StudentT": {"nu": 7, "mu": 0.0, "sigma": 1},
"Triangular": {"lower": -2, "c": 0.0, "upper": 2.0},
"TruncatedNormal": {"mu": 0.0, "sigma": 1, "lower": -2, "upper": 3.0},
Expand Down

0 comments on commit bb7ef2b

Please sign in to comment.