[ ]:
%matplotlib ipympl
import ipywidgets as widgets
import matplotlib.pyplot as plt
import numpy as np

from mpl_interactions import interactive_hist


1. zorder may be funky (this is not calling ax.hist internally)
2. only vertical histograms
3. no stacked histograms
4. currently no labels are possible
    - this one may actually be worth fixing
5. only allows stretching the axis limits - no auto scaling
7. the axis relimming is a bit hacky, may not be exactly equivalent to what you'd get by call plt.hist

There are some limitations to the current approach that could be worked around. But that would require a high amount of effort and all of these limitations should be solved by https://github.com/matplotlib/matplotlib/pull/18275 which be released with matplotlib version 3.4

This accepts the following arguments that are passed through to np.histogram. Here they are with their default values: - density = False - bins = 'auto' - weight = None

f must return

[ ]:
def f(loc, scale):
    return np.random.randn(10000) * scale + loc
[ ]:
fig, ax = plt.subplots()
controls = interactive_hist(f, loc=(0, 10, 100), scale=(0.5, 5))
[ ]:
fig2, ax2 = plt.subplots()
controls2 = interactive_hist(
    f, loc=(0, 10, 100), scale=(0.5, 5), bins=100, density=True
[ ]: