From: K. KISHIMOTO <korry@us...>  20031215 13:38:29

Thank you for your reply. > def func1(x=None): > if x is None: x = [] > #blah blah The indication is right. I should have done so. Thank you. > This seems like the kind of thing that would best be done in your user > library. Eg, if you make a module mymatplotlib.py, you can defined > your own hist. In that file, just import matplotlib.matlab and call > matplotlib.matlab.hist within it. In fact, matplotlib.matlab.hist > calls matplotlib.mlab.hist. I am sorry that my last explanation was insufficient. The point is that I think it is inefficient to execute the following two lines in matplotlib.mlab.hist when I know the result of "n" already. >> n = searchsorted(sort(y), bins) >> n = diff(concatenate([n, [len(y)]])) For the moment, I must insert extra code >> y = [1.0] * 1000 (and hist(y, [0.0, 2.0]) calculates n = [1000], then plot the data.) This is very expensive. Another point is hist() does not support error bar plot (but bar() called from hist() does support.) So, I propose again def hist(x, bins=10, noplot=0, normed=0, weights=None, errors=None , **kwargs): in matplotlib.matplab. I think if matplotlib supports this by default, it is very smart and usefull to many users when making histogram plots with matplotlib than letting hist() be mainly for the purpose of "calculating" histograms. Example rough code.  def hist(x, bins=10, noplot=0, normed=0, weights=None, xerr=None, yerr=None, **kwargs): if noplot: if weights == None: return mlab.hist(x, bins, normed) else: return (weights, bins) else: try: if weights == None: ret = gca().hist(x, bins, normed) else: ret = gca().bar(bins, weights, xerr=xerr, yerr=yerr, **kwargs) except ValueError, msg: msg = raise_msg_to_str(msg) error_msg(msg) raise RuntimeError, msg draw_if_interactive() return ret 