Skip to content

Conversation

@jordandeklerk
Copy link
Member

@jordandeklerk jordandeklerk commented Oct 21, 2025

Closes #353

from arviz_plots import plot_khat
from arviz_base import load_arviz_data
from arviz_stats import loo

dt = load_arviz_data("radon")
elpd_data = loo(dt, pointwise=True)
plot_khat(elpd_data)
image
plot_khat(elpd_data, show_bins=True, show_hlines=True)
image

📚 Documentation preview 📚: https://arviz-plots--356.org.readthedocs.build/en/356/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if the new helpers here should be in the public API or not. Not too sure how frequently these will be used outside of the Pareto shape plot.

@codecov-commenter
Copy link

codecov-commenter commented Oct 21, 2025

Codecov Report

❌ Patch coverage is 76.16099% with 77 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.17%. Comparing base (1e2a7c8) to head (390a471).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
src/arviz_plots/plots/utils.py 54.54% 55 Missing ⚠️
src/arviz_plots/plots/khat_plot.py 90.10% 19 Missing ⚠️
src/arviz_plots/visuals/__init__.py 62.50% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #356      +/-   ##
==========================================
- Coverage   86.17%   85.17%   -1.01%     
==========================================
  Files          54       55       +1     
  Lines        6091     6469     +378     
==========================================
+ Hits         5249     5510     +261     
- Misses        842      959     +117     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jordandeklerk jordandeklerk marked this pull request as ready for review October 21, 2025 13:35
Copy link
Member

@OriolAbril OriolAbril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to leave now, will continue the review tomorrow hopefully it is somewhat helpful already

@jordandeklerk
Copy link
Member Author

I have to leave now, will continue the review tomorrow hopefully it is somewhat helpful already

Very useful, thank you! I will need to re-work somethings you've mentioned already and some that @aloctavodia mentioned as well over slack. Hoping to get these changes in early next week!

Copy link
Member

@OriolAbril OriolAbril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit unsure about the things we'd want to support and the things we don't want to allow. There are several things we could integrate more with plotcollection machinery which would give more flexibility to the plot, but plotcollection also usually gives more flexibility than what is really needed which can end up meaning more work and less clear behaviour.

if fig is None:
return

if not hasattr(fig.canvas, "mpl_connect"):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the right way to handle this? It doesn't seem feasible to check for all possible interactive backends (maybe it is?). This works pretty well right now for me.

@jordandeklerk
Copy link
Member Author

jordandeklerk commented Nov 10, 2025

With the recent changes, I added some more examples to the plot_khat gallery that address row and column facets as well as grid faceting. Let me know what you think of those visuals.

I think this is good for another round of review now.

@jordandeklerk
Copy link
Member Author

Example of hover for interactive matplotlib for the rugby data

Screenshot 2025-11-09 at 11 15 30 PM

@read-the-docs-community
Copy link

read-the-docs-community bot commented Nov 10, 2025

Documentation build overview

📚 arviz-plots | 🛠️ Build #30458815 | 📁 Comparing 390a471 against latest (d493d60)


🔍 Preview build

Show files changed (85 files in total): 📝 75 modified | ➕ 8 added | ➖ 2 deleted
File Status
genindex.html 📝 modified
_modules/index.html 📝 modified
api/index.html 📝 modified
api/plots.html 📝 modified
api/visuals.html 📝 modified
gallery/add_reference_bands.html 📝 modified
gallery/add_reference_lines.html 📝 modified
gallery/combine_plots.html 📝 modified
gallery/index.html 📝 modified
gallery/plot_autocorr.html 📝 modified
gallery/plot_bf.html 📝 modified
gallery/plot_compare.html 📝 modified
gallery/plot_convergence_dist.html 📝 modified
gallery/plot_dist_ecdf.html 📝 modified
gallery/plot_dist_hist.html 📝 modified
gallery/plot_dist_kde.html 📝 modified
gallery/plot_dist_models.html 📝 modified
gallery/plot_ecdf_coverage.html 📝 modified
gallery/plot_ecdf_pit.html 📝 modified
gallery/plot_energy.html 📝 modified
gallery/plot_ess_evolution.html 📝 modified
gallery/plot_ess_local.html 📝 modified
gallery/plot_ess_models.html 📝 modified
gallery/plot_ess_quantile.html 📝 modified
gallery/plot_forest.html 📝 modified
gallery/plot_forest_ess.html 📝 modified
gallery/plot_forest_models.html 📝 modified
gallery/plot_forest_pp_obs.html 📝 modified
gallery/plot_forest_shade.html 📝 modified
gallery/plot_khat.html ➕ added
gallery/plot_khat_aesthetics.html ➕ added
gallery/plot_khat_facet_cols.html ➕ added
gallery/plot_khat_facet_grid.html ➕ added
gallery/plot_loo_pit.html 📝 modified
gallery/plot_mcse.html 📝 modified
gallery/plot_pair.html 📝 modified
gallery/plot_pair_distribution.html 📝 modified
gallery/plot_pair_focus.html 📝 modified
gallery/plot_pair_focus_distribution.html 📝 modified
gallery/plot_parallel.html 📝 modified
gallery/plot_pava_calibration.html 📝 modified
gallery/plot_ppc_censored.html 📝 modified
gallery/plot_ppc_coverage.html 📝 modified
gallery/plot_ppc_dist.html 📝 modified
gallery/plot_ppc_interval.html 📝 modified
gallery/plot_ppc_pit.html 📝 modified
gallery/plot_ppc_rootogram.html 📝 modified
gallery/plot_ppc_tstat.html 📝 modified
gallery/plot_prior_posterior.html 📝 modified
gallery/plot_psense.html 📝 modified
gallery/plot_psense_quantities.html 📝 modified
gallery/plot_rank.html 📝 modified
gallery/plot_rank_dist.html 📝 modified
gallery/plot_ridge.html 📝 modified
gallery/plot_ridge_multiple.html 📝 modified
gallery/plot_trace.html 📝 modified
gallery/plot_trace_dist.html 📝 modified
_modules/arviz_plots/plot_collection.html 📝 modified
_modules/arviz_plots/plot_matrix.html 📝 modified
_modules/arviz_plots/visuals.html 📝 modified
api/generated/arviz_plots.PlotCollection.generate_aes_dt.html 📝 modified
api/generated/arviz_plots.PlotMatrix.map_triangle.html 📝 modified
api/generated/arviz_plots.plot_forest.html 📝 modified
api/generated/arviz_plots.plot_khat.html ➕ added
api/generated/arviz_plots.plot_lm.html 📝 modified
api/generated/arviz_plots.plot_loo_pit.html 📝 modified
api/generated/arviz_plots.plot_ppc_dist.html 📝 modified
api/generated/arviz_plots.plot_ppc_interval.html ➖ deleted
api/generated/arviz_plots.plot_ppc_pava.html 📝 modified
api/generated/arviz_plots.plot_prior_posterior.html 📝 modified
api/generated/arviz_plots.visuals.remove_ticks.html 📝 modified
api/generated/arviz_plots.visuals.set_xlim.html ➕ added
api/generated/arviz_plots.visuals.set_xticks.html 📝 modified
api/generated/arviz_plots.visuals.set_ylim.html ➕ added
api/generated/arviz_plots.visuals.ticklabel_props.html 📝 modified
_modules/arviz_plots/plots/dist_plot.html 📝 modified
_modules/arviz_plots/plots/forest_plot.html 📝 modified
_modules/arviz_plots/plots/khat_plot.html ➕ added
_modules/arviz_plots/plots/lm_plot.html 📝 modified
_modules/arviz_plots/plots/ppc_interval_plot.html ➖ deleted
_modules/arviz_plots/plots/prior_posterior_plot.html 📝 modified
_modules/arviz_plots/plots/psense_quantities_plot.html 📝 modified
_modules/arviz_plots/plots/rank_plot.html 📝 modified
_modules/arviz_plots/plots/utils.html 📝 modified
_modules/arviz_plots/backend/matplotlib/core.html 📝 modified

**khat_kwargs,
)

if show_hlines and hline_values:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hlines should display on top, not behind khat values

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will changing this to zorder=3 resolve that? I think that's what I had before, but changed it based on feedback here. I could be wrong though. I think the problem is that scatter points have zorder=2 as well so which ever is drawn first in plot_khat() takes priority.

Or should I just keep this zorder for hlines and just plot the hlines before the scatter in the actual function so they overlay on top?

@expand_aesthetic_aliases
def hline(y, target, *, color=unset, alpha=unset, width=unset, linestyle=unset, **artist_kws):
    """Interface to matplotlib for a horizontal line spanning the whole axes."""
    artist_kws.setdefault("zorder", 2)
    kwargs = {"color": color, "alpha": alpha, "linewidth": width, "linestyle": linestyle}
    return target.axhline(y, **_filter_kwargs(kwargs, Line2D, artist_kws))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plotting hlines first is ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Pareto shape plot

4 participants