Skip to content

Commit

Permalink
use constant gap for rank plots (#2180)
Browse files Browse the repository at this point in the history
* use constant gap rank plot

* update changelog

* Update arviz/plots/backends/matplotlib/traceplot.py

Co-authored-by: Oriol Abril-Pla <oriol.abril.pla@gmail.com>

* Update CHANGELOG.md

Co-authored-by: Oriol Abril-Pla <oriol.abril.pla@gmail.com>
  • Loading branch information
aloctavodia and OriolAbril authored Dec 8, 2022
1 parent 7091b15 commit 3c82bdd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Fix `reloo` outdated usage of `ELPDData` ([2158](https://github.com/arviz-devs/arviz/pull/2158))
- plot_bpv smooth discrete data only when computing u_values ([2179](https://github.com/arviz-devs/arviz/pull/2179))
- Fix bug when beanmachine objects lack some fields ([2154](https://github.com/arviz-devs/arviz/pull/2154))
- Fix gap for `plot_trace` with option `kind="rank_bars"` ([2180](https://github.com/arviz-devs/arviz/pull/2180))

### Deprecation

Expand All @@ -27,6 +28,7 @@
### Maintenance and fixes
- Fix dimension ordering for `plot_trace` with divergences ([2151](https://github.com/arviz-devs/arviz/pull/2151))


## v0.13.0 (2022 Oct 22)

### New features
Expand Down
2 changes: 1 addition & 1 deletion arviz/plots/backends/matplotlib/rankplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def plot_rank(
all_counts = np.empty((len(ranks), len(bin_ary) - 1))
for idx, row in enumerate(ranks):
_, all_counts[idx], _ = histogram(row, bins=bin_ary)
gap = all_counts.max() * 1.05
gap = 2 / ranks.size
width = bin_ary[1] - bin_ary[0]

bar_kwargs.setdefault("width", width)
Expand Down
3 changes: 3 additions & 0 deletions arviz/plots/backends/matplotlib/traceplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ def plot_trace(
fill_kwargs = matplotlib_kwarg_dealiaser(fill_kwargs, "fill_between")
rug_kwargs = matplotlib_kwarg_dealiaser(rug_kwargs, "scatter")
rank_kwargs = matplotlib_kwarg_dealiaser(rank_kwargs, "bar")
if compact:
rank_kwargs.setdefault("bar_kwargs", {})
rank_kwargs["bar_kwargs"].setdefault("alpha", 0.2)

textsize = plot_kwargs.pop("textsize", 10)

Expand Down

0 comments on commit 3c82bdd

Please # to comment.