Skip to content

Viz 02: Harmonise 1D distribution plots (histogram + KDE)#1718

Draft
Doresic wants to merge 4 commits into
viz-01-cluster-palettefrom
viz-02-1d-distributions
Draft

Viz 02: Harmonise 1D distribution plots (histogram + KDE)#1718
Doresic wants to merge 4 commits into
viz-01-cluster-palettefrom
viz-02-1d-distributions

Conversation

@Doresic
Copy link
Copy Markdown
Contributor

@Doresic Doresic commented May 28, 2026

It makes sense to make parameter_hist and sampling_1d_marginals (the two 1D distribution plotters) to behave the same: same bounds handling, same axis labels, same legend layout, same argument vocabulary, as they are very similar plotters.

Main changes:

  • both functions now take show_bounds: bool = True — when true, the plot frames to the parameter bounds and draws bound lines; when false, it frames tightly to the data. xlim is set explicitly from bounds + actual data, so the KDE tail extension never dominates the visible range
  • scale-aware x-labels (log parameters get a log-scale axis label)
  • per-panel legend with KDE / Samples / Bounds entries
  • rug uses the darker dash_color (matching the bar-edge family) so individual data points stay readable on the lighter histogram
  • new shared helper plot_density_panel in misc.py doing the histogram / KDE / rug / bounds rendering — takes a resolved style dict
  • harmonised the two siblings' arguments: same shared-kwarg order (plot_type, bins, bw_method, show_bounds, title, size, ax/axes, style_kwargs), and sampling_1d_marginals gained bins (was hardcoded). Tidied up some confusing docstrings along the way (stepsize is a thinning factor; start_indices subsets starts while parameter_indices subsets parameters)
  • new apply_style() in _style.py — a small opt-in rcParams preset (top/right spines off, framed legends, constrained layout). General so later PRs in the series just call it
  • new generic style keys: LINE_* for any line (KDE, simulation, …), DASH_* for any tick marker (rug, CI endpoints, …). The naming principle is documented in _style.py so future PRs follow it
  • parameter_hist gains bw_method and title; its legacy color kwarg is deprecated — use style_kwargs={"rectangle_color": ..., "line_color": ..., "dash_color": ...} instead
  • process_deprecated_kwarg in misc.py gains a removal mode (canonical_name=None) and a note= parameter for custom messages — used here for the color deprecation; PR 09b will reuse it
  • GRID_SIZE_PER_COL / GRID_SIZE_PER_ROW in _style.py wire into get_axes_array's size=None default so every multi-panel plotter inherits consistent panel sizing

This is the second in the small series of visualisation PRs. Before/after PNGs below.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 28, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 90.19608% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.38%. Comparing base (450b571) to head (0ded28c).

Files with missing lines Patch % Lines
pypesto/visualize/misc.py 76.19% 10 Missing ⚠️
pypesto/visualize/_style.py 91.30% 4 Missing ⚠️
pypesto/visualize/sampling.py 97.14% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@                    Coverage Diff                     @@
##           viz-01-cluster-palette    #1718      +/-   ##
==========================================================
+ Coverage                   84.33%   84.38%   +0.05%     
==========================================================
  Files                         165      165              
  Lines                       14796    14926     +130     
==========================================================
+ Hits                        12478    12596     +118     
- Misses                       2318     2330      +12     

☔ 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.

@Doresic
Copy link
Copy Markdown
Contributor Author

Doresic commented May 28, 2026

Here are the plot comparisons
before and after
Histograms before:
parameter_hist__before
Histograms after:
parameter_hist__after
1d-sampling-marginals before:
sampling_1d_marginals__before
1d-sampling-marginals after no bounds:
sampling_1d_marginals__after_no_bounds
1d-sampling-marginals after with bounds:
sampling_1d_marginals__after

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.

2 participants