mcerp: error while plotting a histogram - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: mcerp: error while plotting a histogram (/thread-2639.html) |
mcerp: error while plotting a histogram - rakhmadiev - Mar-30-2017 Hi guys, python returns an error while plotting a histogram in mcerp module. I am able to plot Kernel Density Estimate plot , but plotting a histogram returns an error: TypeError: 'numpy.float64' object cannot be interpreted as an integer. I am using Python 3.6 64 bit for Windows This is a code that returns an error: from mcerp import * from matplotlib import pyplot as plt x1 = N(24,1) x2 = N(37,4) x4=x1*x2 x4.plot(hist=True) # if I change to x4.plot() the code works fine, but returns KDE plot only plt.show() Moderator Larz60+: Added python tags -- Please do this in the futue (see help: BBcode)
RE: mcerp: error while plotting a histogram - zivoni - Mar-30-2017 I installed mcerp-0.11 and tried it, it seems that it depends on ancient version of matplotlib with plt.histogram() that could accept float for number of bins. Unfortunately mcerp doesnt specify exact dependencies and actual version of matplotlib needs bins to be integer (or list with partition), so I changed lines 260 and 660 in mcerp/__init__.py fromh = plt.hist(vals, bins=np.round(np.sqrt(len(vals))), histtype='stepfilled', normed=True, **kwargs)to (replaced np.round with int), h = plt.hist(vals, bins=int(np.sqrt(len(vals))), histtype='stepfilled', normed=True, **kwargs)after that your code worked. You have multiple options what to do:
RE: mcerp: error while plotting a histogram - rakhmadiev - Apr-02-2017 Thanks! It worked indeed. But for some reason python referenced __init__ file in .egg archive... Anyway thank you for prompt response. |