Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding New Rootogram Plot #81

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ classifiers = [
dynamic = ["version", "description"]
dependencies = [
"arviz-base==0.2",
"arviz-stats[xarray]==0.2",
"arviz-stats[xarray] @ git+https://github.com/arviz-devs/arviz-stats@get_bins",
]

[tool.flit.module]
Expand Down
6 changes: 2 additions & 4 deletions src/arviz_plots/backend/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,15 @@ def hist(
artist_kws.setdefault("zorder", 2)
widths = np.asarray(r_e) - np.asarray(l_e)
if np.any(bottom != 0):
height = y - bottom
else:
height = y
y = y - bottom # making y the top coordinate and not height
if color is not unset:
if facecolor is unset:
facecolor = color
if edgecolor is unset:
edgecolor = color
kwargs = {"bottom": bottom, "color": facecolor, "edgecolor": edgecolor, "alpha": alpha}
return target.bar(
l_e, height, width=widths, align="edge", **_filter_kwargs(kwargs, None, artist_kws)
l_e, y, width=widths, align="edge", **_filter_kwargs(kwargs, None, artist_kws)
)


Expand Down
16 changes: 13 additions & 3 deletions src/arviz_plots/backend/none/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,19 @@ def _filter_kwargs(kwargs, artist_kws):
return {**artist_kws, **kwargs}


# "geoms"
def hist(
y, l_e, r_e, target, *, bottom=None, color=unset, facecolor=unset, edgecolor=unset, **artist_kws
y,
l_e,
r_e,
target,
*,
bottom=None,
color=unset,
alpha=unset,
facecolor=unset,
edgecolor=unset,
**artist_kws,
):
"""Interface to matplotlib for a histogram bar plot."""
if not ALLOW_KWARGS and artist_kws:
Expand All @@ -200,7 +211,7 @@ def hist(
facecolor = color
if edgecolor is unset:
edgecolor = color
kwargs = {"bottom": bottom, "facecolor": facecolor, "edgecolor": edgecolor}
kwargs = {"bottom": bottom, "alpha": alpha, "facecolor": facecolor, "edgecolor": edgecolor}
artist_element = {
"function": "hist",
"l_e": np.atleast_1d(l_e),
Expand All @@ -212,7 +223,6 @@ def hist(
return artist_element


# "geoms"
def line(x, y, target, *, color=unset, alpha=unset, width=unset, linestyle=unset, **artist_kws):
"""Interface to a line plot."""
kwargs = {"color": color, "alpha": alpha, "width": width, "linestyle": linestyle}
Expand Down
2 changes: 2 additions & 0 deletions src/arviz_plots/plots/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .distplot import plot_dist
from .forestplot import plot_forest
from .ridgeplot import plot_ridge
from .rootogramplot import plot_rootogram
from .tracedistplot import plot_trace_dist
from .traceplot import plot_trace

Expand All @@ -14,4 +15,5 @@
"plot_trace",
"plot_trace_dist",
"plot_ridge",
"plot_rootogram",
]
5 changes: 4 additions & 1 deletion src/arviz_plots/plots/distplot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""dist plot code."""

import warnings
from copy import copy
from importlib import import_module
Expand Down Expand Up @@ -358,7 +359,9 @@ def plot_dist(
point_density_diff = [
dim for dim in density.sel(plot_axis="histogram").dims if dim not in point.dims
]
point_density_diff = ["hist_dim"] + point_density_diff
point_density_diff = [
f"hist_dim_{var_name}" for var_name in density.data_vars
] + point_density_diff
point_y = 0.04 * density.sel(plot_axis="histogram", drop=True).max(
dim=point_density_diff
)
Expand Down
Loading