Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #100687
| From | Peter Pearson <pkpearson@nowhere.invalid> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: What could cause a plot fail in my code? |
| Date | 2015-12-21 17:54 +0000 |
| Message-ID | <ddqsn1Fqf06U1@mid.individual.net> (permalink) |
| References | <22c809c7-3aaf-4439-b919-8de982d7ffc9@googlegroups.com> <af6b23d0-225b-42cc-9f53-114e07091ba0@googlegroups.com> |
On Mon, 21 Dec 2015 09:29:24 -0800 (PST), Robert <rxjwg98@gmail.com> wrote: > On Monday, December 21, 2015 at 12:15:54 PM UTC-5, Robert wrote: >> Hi, >> >> I find a useful code snippet on link: >> >> http://stackoverflow.com/questions/25126444/logistic-regression-in-pymc/34400966#34400966 >> >> but it has error on plot function. The error message is as following: >> --------- >> %run "C:\Users\rj\pyprj\logic_regression0.py" >> [-----------------100%-----------------] 10000 of 10000 complete in 12.6 secPlotting beta0 >> Plotting tau >> Plotting betaSalad >> Plotting sigma >> --------------------------------------------------------------------------- >> UnboundLocalError Traceback (most recent call last) >> C:\Users\pyprj\logic_regression0.py in <module>() >> 34 #m.sample(100000, 50000, 50) >> 35 m.sample(10000, 5000, 50) >> ---> 36 pm.Matplot.plot(m) >> 37 import matplotlib.pyplot as plt >> 38 #plt.plot(m) >> >> C:\Users\AppData\Local\Enthought\Canopy\User\lib\site- packages\pymc\Matplot.pyc in wrapper(pymc_obj, *args, **kwargs) >> 339 if args: >> 340 name = '%s_%s' % (args[0], variable.__name__) >> --> 341 f(data, name, *args, **kwargs) >> 342 return >> 343 except AttributeError: >> >> C:\Users\AppData\Local\Enthought\Canopy\User\lib\site-packages\pymc\Matplot.pyc in plot(data, name, format, suffix, path, common_scale, datarange, new, last, rows, num, fontmap, verbose) >> 453 num=num * 2, >> 454 last=last, >> --> 455 fontmap=fontmap) >> 456 >> 457 if last: >> >> C:\Users\AppData\Local\Enthought\Canopy\User\lib\site-packages\pymc\Matplot.pyc in wrapper(pymc_obj, *args, **kwargs) >> 375 >> 376 # If others fail, assume that raw data is passed >> --> 377 f(pymc_obj, *args, **kwargs) >> 378 >> 379 wrapper.__doc__ = f.__doc__ >> >> C:\Users\AppData\Local\Enthought\Canopy\User\lib\site-packages\pymc\Matplot.pyc in histogram(data, name, bins, datarange, format, suffix, path, rows, columns, num, last, fontmap, verbose) >> 576 >> 577 # Generate histogram >> --> 578 hist(data.tolist(), bins, histtype='stepfilled') >> 579 >> 580 xlim(datarange) >> >> C:\Users\AppData\Local\Enthought\Canopy\User\lib\site-packages\matplotlib\pyplot.py in hist(x, bins, range, normed, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, hold, data, **kwargs) >> 2956 histtype=histtype, align=align, orientation=orientation, >> 2957 rwidth=rwidth, log=log, color=color, label=label, >> -> 2958 stacked=stacked, data=data, **kwargs) >> 2959 finally: >> 2960 ax.hold(washold) >> >> C:\Users\AppData\Local\Enthought\Canopy\User\lib\site-packages\matplotlib\__init__.py in inner(ax, *args, **kwargs) >> 1809 warnings.warn(msg % (label_namer, func.__name__), >> 1810 RuntimeWarning, stacklevel=2) >> -> 1811 return func(ax, *args, **kwargs) >> 1812 pre_doc = inner.__doc__ >> 1813 if pre_doc is None: >> >> C:\Users\AppData\Local\Enthought\Canopy\User\lib\site-packages\matplotlib\axes\_axes.py in hist(self, x, bins, range, normed, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, **kwargs) >> 6192 ymin = np.amin(m[m != 0]) >> 6193 # filter out the 0 height bins >> -> 6194 ymin = max(ymin*0.9, minimum) if not input_empty else minimum >> 6195 ymin = min(ymin0, ymin) >> 6196 self.dataLim.intervaly = (ymin, ymax) >> >> UnboundLocalError: local variable 'ymin' referenced before assignment >> ///////////// >> >> I have no clue at all on debug it. Could you help me? >> Thanks, > > Excuse me. The code link should be this one: > > http://nbviewer.ipython.org/gist/aflaxman/8329ec1b9f861469f896 > > Do you experience such errors? From a quick look, it appears that you are trying to plot a histogram in which all the bins are empty. -- To email me, substitute nowhere->runbox, invalid->com.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
What could cause a plot fail in my code? Robert <rxjwg98@gmail.com> - 2015-12-21 09:15 -0800
Re: What could cause a plot fail in my code? Robert <rxjwg98@gmail.com> - 2015-12-21 09:29 -0800
Re: What could cause a plot fail in my code? Peter Pearson <pkpearson@nowhere.invalid> - 2015-12-21 17:54 +0000
Re: What could cause a plot fail in my code? Peter Otten <__peter__@web.de> - 2015-12-21 19:10 +0100
Re: What could cause a plot fail in my code? Denis McMahon <denismfmcmahon@gmail.com> - 2015-12-22 14:12 +0000
csiph-web