Re: [Matplotlib-users] bug with bar graph when plotting zero values?
On Thursday, September 27, 2012, Pierre Haessig wrote: Hi Paul, Le 26/09/2012 18:14, Paul Tremblay a écrit : I noticed today that when I create a bar graph with zero values that the labels don't align correctly: When I run your code with defects = [0, 0, 0, 5, 6, 7], I don't notice a misalignment of xlabels, but rather a issue with xaxis scaling being different (and not very good). So it would be more an issue of xaxis autoscaling. Maybe you can send a link to your saved figure to check we are talking of the same thing. I've attached my figures (manual 3 panels composition). Also, I've noticed that the xscaling issue doesn't come from zero values in general, but from defects[0] being zero. Best, Pierre This issue has been mentioned before. The problem happens for a zero bar on either end. Particularly, a bar with zero height does not register a bbox for determining the axis limits. We will likely need a slightly different way of autoscaling for bar() Ben Root -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://ad.doubleclick.net/clk;258768047;13503038;j? http://info.appdynamics.com/FreeJavaPerformanceDownload.html___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] bug with bar graph when plotting zero values?
On Thu, Sep 27, 2012 at 1:07 PM, Benjamin Root ben.r...@ou.edu wrote: On Thursday, September 27, 2012, Pierre Haessig wrote: Hi Paul, Le 26/09/2012 18:14, Paul Tremblay a écrit : I noticed today that when I create a bar graph with zero values that the labels don't align correctly: When I run your code with defects = [0, 0, 0, 5, 6, 7], I don't notice a misalignment of xlabels, but rather a issue with xaxis scaling being different (and not very good). So it would be more an issue of xaxis autoscaling. Maybe you can send a link to your saved figure to check we are talking of the same thing. I've attached my figures (manual 3 panels composition). Also, I've noticed that the xscaling issue doesn't come from zero values in general, but from defects[0] being zero. Best, Pierre This issue has been mentioned before. The problem happens for a zero bar on either end. Particularly, a bar with zero height does not register a bbox for determining the axis limits. We will likely need a slightly different way of autoscaling for bar() Ben Root As an epic hack/workaround. Could you set bars of zero height to instead be of height, 10e-5. Or something small compared to whatever the current scale on the y-axis is. Or call ax.set_xlim yourself after plotting? It's not ideal, but does it help? Like Ben said, the bbox should account for all possible bar locations, regardless of height, for this to behave as expected. -- Damon McDougall http://www.damon-is-a-geek.com B2.39 Mathematics Institute University of Warwick Coventry West Midlands CV4 7AL United Kingdom -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://ad.doubleclick.net/clk;258768047;13503038;j? http://info.appdynamics.com/FreeJavaPerformanceDownload.html ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] bug with bar graph when plotting zero values?
I noticed today that when I create a bar graph with zero values that the labels don't align correctly: import matplotlib.pyplot as plt import numpy as np fig = plt.figure() names = ['name a', 'name b', 'name c', 'named', 'name e', 'name f'] defects = [0, 0, 0, 5, 6, 7] ax = fig.add_subplot(111) widths=.75 ind = np.arange(len(defects)) # the x locations for the groups ind = ind + widths bar = ax.bar(ind, defects, width=widths) plt.xticks(ind + widths/2.0 , names, rotation=90) ax.set_xlabel('Sorter') ax.set_ylabel('Percentage (Average)') plt.subplots_adjust( bottom=0.30) ax.yaxis.grid(True, linestyle='-', which='major', color='lightgrey', alpha=0.5) ax.set_axisbelow(True) plt.savefig('temp.png') defects = [1, 2, 3, 5, 6, 7] # same code... When run with the defects with non zero values, the labels appear as I expect; with zero values, the left label aligns incorrectly with the y axis. Thanks P. -- How fast is your code? 3 out of 4 devs don\\\'t know how their code performs in production. Find out how slow your code is with AppDynamics Lite. http://ad.doubleclick.net/clk;262219672;13503038;z? http://info.appdynamics.com/FreeJavaPerformanceDownload.html___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] bug on bar?
Hi all, I've got a strange problem with bar, it seems that xticks are not correctly draw: |remi|[16]years Out [16]:[1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006] |remi|[17]maxis Out [17]:[137.25, 124.5, 125.125, 125.375, 176.5, 148.625, 145.875, 150.375] |remi|[18]bar(years,maxis,align='center') gives the figure in the sc.png. But if we happend one data in years and in maxis, xticks are good! Is it a bug? PS:mpl version 0.87.7. -- Lionel Roubeyrie - [EMAIL PROTECTED] LIMAIR http://www.limair.asso.fr sc.png Description: PNG image - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users