Bar plot, 0 values

Hi there,

While creating bar plots I found that bars with height 0 are not being
displayed. Their space is distributed evenly between the other
columns.

Sample script:
/--------------------------------------
from pylab import *
import sys
figure(8)
if(sys.argv[1].lower() == 'y'):
    bar([0, 1, 0, 0, 0], [0, 1, 0, 0, 0])
else:
    bar([1, 2, 3, 4, 5], [1, 2, 3, 4, 5])
show()
\--------------------------------------

Try it with argument 'y' and without.

So far I didn't find a solution. '0' is not an easy thing to google
:slight_smile: Anyone got an idea?

Cheers, B.

With the current svn, I cannot reproduce the problem, i.e., bars with
0 height are correctly displayed. The x-range is incorrectly set, but
it is not clear if this is what you meant.

Can you post a screenshot of your figure? Also, version of your
matplotlib will be helpful.

Regards,

-JJ

···

On Wed, Mar 24, 2010 at 10:46 PM, b b <cook.strait.giant.weta@...287...> wrote:

Hi there,

While creating bar plots I found that bars with height 0 are not being
displayed. Their space is distributed evenly between the other
columns.

Sample script:
/--------------------------------------
from pylab import *
import sys
figure(8)
if(sys.argv[1].lower() == 'y'):
bar([0, 1, 0, 0, 0], [0, 1, 0, 0, 0])
else:
bar([1, 2, 3, 4, 5], [1, 2, 3, 4, 5])
show()
\--------------------------------------

Try it with argument 'y' and without.

So far I didn't find a solution. '0' is not an easy thing to google
:slight_smile: Anyone got an idea?

Cheers, B.

------------------------------------------------------------------------------
Download Intel&#174; 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

Hi,

Here's a version that goes to the list too :slight_smile:

With the current svn, I cannot reproduce the problem, i.e., bars with
0 height are correctly displayed. The x-range is incorrectly set, but
it is not clear if this is what you meant.

Uhm I tried to use the svn trunk on revision 8214 but it wouldn't
display anything. The script just runs and doesn't open any window.

Anyway the script wasn't quite working, here's an update:
/---------------------------------------------
from pylab import *
import sys
figure(8)
if(len(sys.argv) > 1 and sys.argv[1].lower() == 'y'):
   bar([1, 2, 3, 4, 5], [0, 1, 0, 0, 0])
else:
   bar([1, 2, 3, 4, 5], [1, 2, 3, 4, 5])
show()
\---------------------------------------------

Can you post a screenshot of your figure? Also, version of your
matplotlib will be helpful.

Should have thought of that myself, thanks ... The issue occurs with
0.98.3-4ubuntu1 as well as with 0.99.0-1ubuntu1.

Also I had the script save the bar charts. Here's what it produced: if
branch http://img153.imageshack.us/img153/7817/01000.png / else branch
http://img87.imageshack.us/img87/3021/12345my.png .

Thanks for the help.
Cheers, B.

···

On Fri, Mar 26, 2010 at 9:10 AM, Jae-Joon Lee <lee.j.joon@...287...> wrote:

I think it is just that the x-range is wrongly set.
Try something like

xlim(1, 6)
ylim(-1, 2)

You will see zero-height rectangles.

Currently, zero-height rectangles are ignored for autoscaling x- and y-axis.
Regards,

-JJ

···

On Thu, Mar 25, 2010 at 6:50 PM, b b <cook.strait.giant.weta@...287...> wrote:

Hi,

Here's a version that goes to the list too :slight_smile:

On Fri, Mar 26, 2010 at 9:10 AM, Jae-Joon Lee <lee.j.joon@...287...> wrote:

With the current svn, I cannot reproduce the problem, i.e., bars with
0 height are correctly displayed. The x-range is incorrectly set, but
it is not clear if this is what you meant.

Uhm I tried to use the svn trunk on revision 8214 but it wouldn't
display anything. The script just runs and doesn't open any window.

Anyway the script wasn't quite working, here's an update:
/---------------------------------------------
from pylab import *
import sys
figure(8)
if(len(sys.argv) > 1 and sys.argv[1].lower() == 'y'):
bar([1, 2, 3, 4, 5], [0, 1, 0, 0, 0])
else:
bar([1, 2, 3, 4, 5], [1, 2, 3, 4, 5])
show()
\---------------------------------------------

Can you post a screenshot of your figure? Also, version of your
matplotlib will be helpful.

Should have thought of that myself, thanks ... The issue occurs with
0.98.3-4ubuntu1 as well as with 0.99.0-1ubuntu1.

Also I had the script save the bar charts. Here's what it produced: if
branch http://img153.imageshack.us/img153/7817/01000.png / else branch
http://img87.imageshack.us/img87/3021/12345my.png .

Thanks for the help.
Cheers, B.

Hi Lee,

That was it. It took me a few more minutes to find out that set_xlim
and set_ylim are methods in of the figure but now it's working nicely.
I also found that the set_[xy]lim methods have to be called after the
bar() method.

Updated script:
/----------------------------------------
from pylab import *
import sys
fig = figure()
ax = fig.add_subplot(111)
if(len(sys.argv) > 1 and sys.argv[1].lower() == 'y'):
    ax.bar([1, 2, 3, 4, 5], [0, 1, 0, 0, 0])
else:
    ax.bar([1, 2, 3, 4, 5], [1, 2, 3, 4, 5])
ax.set_xlim(0, 6)
show()
\----------------------------------------

The output is at http://img149.imageshack.us/img149/9302/updatedf.png .

Thanks a lot.

···

On Fri, Mar 26, 2010 at 3:12 PM, Jae-Joon Lee <lee.j.joon@...287...> wrote:

I think it is just that the x-range is wrongly set.
Try something like

xlim(1, 6)
ylim(-1, 2)

You will see zero-height rectangles.

Currently, zero-height rectangles are ignored for autoscaling x- and y-axis.
Regards,