Thanks Friedrich, I though the width was calculated on the fly. does it make sense to use something like plt.bar(bins, nb_per_bin, width=(max(bins)-min(bins)) / (1.5*len(bins))) If I want something more generic
Tim Friedrich Romstedt wrote: > You must give a proper :param width: argument: > > plt.bar(bins, height, 0.01) > > http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.bar > > Friedrich > > 2010/3/25 timothee cezard <tcez...@staffmail.ed.ac.uk>: > >> Hi all, >> I'm trying to plot a distribution using bar() but when I'm setting the >> left variable to as a sequence of float some of the bar look weird. >> When I replace this sequence by a sequence of int it works fines >> Does anybody know why this happens and how I can fix it? >> >> Here is the code I'm using: >> >> if __name__=="__main__": >> bins=[0.0, 0.02, 0.04, 0.06, 0.08, 0.1, 0.12, 0.14, 0.16, >> 0.18, 0.2, 0.22, 0.24, 0.26, 0.28, 0.30, 0.32, 0.34, >> 0.36, 0.38, 0.40, 0.42, 0.44, 0.46, 0.48, 0.5, 0.52, >> 0.54, 0.56, 0.58, 0.60, 0.62, 0.64, 0.66, 0.68, 0.70, >> 0.72, 0.74, 0.76, 0.78, 0.80, 0.82, 0.84, 0.86, 0.88, >> 0.90, 0.92, 0.94, 0.96, 0.98, 1.0] >> height=[89775, 1665, 1791, 1695, 1467, 1395, 1306, 1169, >> 1252, 1134, 1190, 1117, 1018, 995, 1055, 904, 960, >> 886, 810, 821, 829, 763, 766, 857, 737, 862, 724, >> 852, 742, 644, 733, 679, 630, 672, 665, 659, 663, >> 653, 657, 700, 731, 721, 699, 871, 837, 913, 940, >> 966, 1028, 159774, 40002] >> fig = plt.figure() >> ax = fig.add_subplot(1,1,1) >> plt.bar(bins, height) >> plt.show() >> > > -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users