Log scale for horizontal bar chart (2 bugs)

Hello,

I've encountered two bugs recently in matplotlib. I am hoping someone
can tell me if these are known issues and if any workarounds have been
proposed. The bug occurs for horizontal bar chart where the x-axis has
a log scale:

from pylab import *

val = 3+10*rand(5) # the bar lengths
pos = arange(5)+.5 # the bar centers on the y axis

axes = subplot(111)
axes.barh(pos,val, align='center')
axes.set_xscale('log')

for a in axes.yaxis.majorTicks:
  a.tick1On=False
  a.tick2On=False

for a in axes.xaxis.majorTicks:
  a.tick1On=True
  a.tick2On=False

for loc, spine in axes.spines.iteritems():
  if loc in ['left','right','top']:
      spine.set_color('none')

show()

If you run this code, you will see that only the end caps of the
horizontal bars are drawn. Furthermore, tick marks appear at the top
of the plot (despite explicitly turning them off). If a linear scale
is used the plot is generated as expected. The issue with tick marks
appearing incorrectly with log axes appears to occur with many types
of graphs (well, at least the three I tried).

Can anyone suggest how I might plot a bar chart with a log scale? Is
there any other way I might force the tick marks at the top to not be
drawn?

Thanks for any and all help.

Cheers,
Donovan

Just wanted to chime in here and note that a similar issue can occur with boxplots and log-scales. I think the issue here is that the rectangle patch is told to draw at the patch length at *zero*. Since there is no zero on a log scale, the rectangle patch is not fully rendered. That's just my observation/hypothesis.

Good luck,
-paul

···

-----Original Message-----
From: Donovan Parks [mailto:donovan.parks@…287…]
Sent: Wednesday, October 14, 2009 1:31 PM
To: matplotlib-users@lists.sourceforge.net
Subject: [Matplotlib-users] Log scale for horizontal bar chart (2
bugs)

Hello,

I've encountered two bugs recently in matplotlib. I am hoping someone
can tell me if these are known issues and if any workarounds have been
proposed. The bug occurs for horizontal bar chart where the x-axis has
a log scale:

from pylab import *

val = 3+10*rand(5) # the bar lengths
pos = arange(5)+.5 # the bar centers on the y axis

axes = subplot(111)
axes.barh(pos,val, align='center')
axes.set_xscale('log')

for a in axes.yaxis.majorTicks:
  a.tick1On=False
  a.tick2On=False

for a in axes.xaxis.majorTicks:
  a.tick1On=True
  a.tick2On=False

for loc, spine in axes.spines.iteritems():
  if loc in ['left','right','top']:
      spine.set_color('none')

show()

If you run this code, you will see that only the end caps of the
horizontal bars are drawn. Furthermore, tick marks appear at the top
of the plot (despite explicitly turning them off). If a linear scale
is used the plot is generated as expected. The issue with tick marks
appearing incorrectly with log axes appears to occur with many types
of graphs (well, at least the three I tried).

barh takes an optional argument "log". set this True (or you may set
"left" with some meaningful value, other than 0)

http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.barh

-JJ

···

On Wed, Oct 14, 2009 at 4:30 PM, Donovan Parks <donovan.parks@...287...> wrote:

Hello,

I've encountered two bugs recently in matplotlib. I am hoping someone
can tell me if these are known issues and if any workarounds have been
proposed. The bug occurs for horizontal bar chart where the x-axis has
a log scale:

from pylab import *

val = 3+10*rand(5) # the bar lengths
pos = arange(5)+.5 # the bar centers on the y axis

axes = subplot(111)
axes.barh(pos,val, align='center')
axes.set_xscale('log')

for a in axes.yaxis.majorTicks:
a.tick1On=False
a.tick2On=False

for a in axes.xaxis.majorTicks:
a.tick1On=True
a.tick2On=False

for loc, spine in axes.spines.iteritems():
if loc in ['left','right','top']:
spine.set_color('none')

show()

If you run this code, you will see that only the end caps of the
horizontal bars are drawn. Furthermore, tick marks appear at the top
of the plot (despite explicitly turning them off). If a linear scale
is used the plot is generated as expected. The issue with tick marks
appearing incorrectly with log axes appears to occur with many types
of graphs (well, at least the three I tried).

Can anyone suggest how I might plot a bar chart with a log scale? Is
there any other way I might force the tick marks at the top to not be
drawn?

Thanks for any and all help.

Cheers,
Donovan

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users