arviz-devs / arviz

Exploratory analysis of Bayesian models with Python
https://python.arviz.org
Apache License 2.0
1.6k stars 397 forks source link

adapt histograms to float/int #2247

Closed OriolAbril closed 1 year ago

OriolAbril commented 1 year ago

Description

The align="left" we used as default in matplotlib distplot is great for ints, but super confusing for floats (which are also valid histogram input via kind kwarg and/or rcparam). The plot below shows the issue:

imatge

bokeh distplot used a mid/centered bins approach which is great for floats, but requires remembering that intervals are [left_edge, right_edge) for ints. Now both should behave in the same way, in both cases plotting histograms adapted to the dtype of the input.

Checklist


:books: Documentation preview :books:: https://arviz--2247.org.readthedocs.build/en/2247/

codecov[bot] commented 1 year ago

Codecov Report

Merging #2247 (2b0a072) into main (61bda88) will increase coverage by 0.00%. The diff coverage is 90.00%.

@@           Coverage Diff           @@
##             main    #2247   +/-   ##
=======================================
  Coverage   87.90%   87.91%           
=======================================
  Files         120      120           
  Lines       12417    12424    +7     
=======================================
+ Hits        10915    10922    +7     
  Misses       1502     1502           
Impacted Files Coverage Δ
arviz/plots/backends/matplotlib/distplot.py 92.85% <87.50%> (+0.54%) :arrow_up:
arviz/plots/backends/bokeh/distplot.py 84.84% <100.00%> (+0.47%) :arrow_up: