I do not know how to make the plots plot_pdf
and hist
appear in the same figure, so I used a “dirty” method with plt.gcf()
. What would be a better way of doing this?
import numpy as np
from matplotlib.figure import Figure
from fitter import Fitter # pip install fitter
from matplotlib import pyplot as plt
randomData = np.random.normal(0, 1, 1000)
def plotOfFittedDistributions(data):
f = Fitter(data, distributions=['gamma', "norm", 'invgauss'], timeout=100)
f.fit()
f.hist()
f.plot_pdf()
ax = plt.gcf()
return ax
fig = pn.bind(plotOfFittedDistributions, data=randomData)