Probabilistic-Programming-and-Bayesian-Methods-for-Hackers
Probabilistic-Programming-and-Bayesian-Methods-for-Hackers copied to clipboard
Chapter 6 issue: ValueError: num must be 1 <= num <= 4, not 0
Hi, found this issue in Chapter 6, changing plt.subplot(2, 2, i) to plt.subplot(2, 2, i+1) fixes the issue with the indexes, but you might want to adopt a different approach not sure why it doesn`t accept 0 for an index.
ValueError Traceback (most recent call last)
... missing stack trace subplots.pyc in init(self, fig, _args, _kwargs) 62 raise ValueError( 63 "num must be 1 <= num <= {maxn}, not {num}".format( ---> 64 maxn=rowscols, num=num)) 65 self._subplotspec = GridSpec(rows, cols)[int(num) - 1] 66 # num - 1 for converting from MATLAB to python indexing
ValueError: num must be 1 <= num <= 4, not 0
you have to add 1 to this line
plt.subplot(2, 2, i + 1)
data[['type']].astype(np.int0) .hist(figsize = (10, 5))
@rodriguesra
you have to add 1 to this line
plt.subplot(2, 2, i + 1)
this works thank you.
Please check the no of the subplots created (rows x columns) and the total no. of plots? They should be equal.