Histogram orientation

Hi,

The following code fails for me with matplotlib-0.90.0 –

axes.patch (559 Bytes)

···

import pylab as pl

x = pl.randn(1000)

pl.hist(x, orientation=‘horizontal’)

pl.show()

This is because Axes.barh() [called by Axes.hist() in axes.py] doesn’t accept the keyword argument ‘log’. The attached patch fixes the problem for my purposes (linear scaling of the axes) but obviously fails to scale the bin count axis correctly if hist() is called with log=True i.e. pl.hist(x, orientation=‘horizontal’, log=True).

It appears that this is still the case in the latest svn version of axes.py.

Cheers,

Scott

Please find our Email Disclaimer here–>:
http://www.ukzn.ac.za/disclaimer

Scott,

In svn, barh does accept the 'log' kwarg via **kwargs, and your example works correctly. Here is the relevant CHANGELOG entry, after 0.90 was released:

2007-03-03 Change barh to take a kwargs dict and pass it to bar.
            Fixes sf bug #1669506.

I think it was just a matter of changing the barh signature to:

     def barh(self, bottom, width, height=0.8, left=None, **kwargs):

but I haven't looked back at the svn records to check that.

Eric

Scott Sinclair wrote:

···

Hi,
The following code fails for me with matplotlib-0.90.0 --
---------------------------------------------------
import pylab as pl
x = pl.randn(1000)
pl.hist(x, orientation='horizontal')
pl.show()
---------------------------------------------------
This is because Axes.barh() [called by Axes.hist() in axes.py] doesn't accept the keyword argument 'log'. The attached patch fixes the problem for my purposes (linear scaling of the axes) but obviously fails to scale the bin count axis correctly if hist() is called with log=True i.e. pl.hist(x, orientation='horizontal', log=True).
It appears that this is still the case in the latest svn version of axes.py.
Cheers,
Scott

Please find our Email Disclaimer here-->: _ http://www.ukzn.ac.za/disclaimer/>_

------------------------------------------------------------------------

--- axes.py 2007-01-22 18:57:58.000000000 +0200
+++ patched_axes.py 2007-04-30 15:12:15.921875000 +0200
@@ -4462,7 +4462,7 @@
         if width is None: width = 0.9*(bins[1]-bins[0])
         if orientation == 'horizontal':
             patches = self.barh(bins, n, height=width, left=bottom,
- align=align, log=log)
+ align=align)
         elif orientation == 'vertical':
             patches = self.bar(bins, n, width=width, bottom=bottom,
                                 align=align, log=log)

------------------------------------------------------------------------

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

------------------------------------------------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

I see.

I only checked that the code in hist() hadn’t changed. I guess it pays to be thorough. Hope this didn’t waste too much time.

Cheers,

Scott

Eric Firing <efiring@…202…> 4/30/2007 20:02 >>>
Scott,
In svn, barh does accept the ‘log’ kwarg via **kwargs, and your example
works correctly. Here is the relevant CHANGELOG entry, after 0.90 was
released:
2007-03-03 Change barh to take a kwargs dict and pass it to bar.
Fixes sf bug #1669506.
I think it was just a matter of changing the barh signature to:
def barh(self, bottom, width, height=0.8, left=None, **kwargs):
but I haven’t looked back at the svn records to check that.
Eric
Scott Sinclair wrote:
Hi,

The following code fails for me with matplotlib-0.90.0 –


import pylab as pl

x = pl.randn(1000)

pl.!
hist(x, orientation=‘horizontal’)

···

pl.show()

This is because Axes.barh() [called by Axes.hist() in axes.py] doesn’t
accept the keyword argument ‘log’. The attached patch fixes the problem
for my purposes (linear scaling of the axes) but obviously fails to
scale the bin count axis correctly if hist() is called with log=True
i.e. pl.hist(x, orientation=‘horizontal’, log=True).

It appears that this is still the case in the latest svn version of axes.py.

Cheers,
Scott

Please find our Email Disclaimer here–>: _
http://www.ukzn.ac.za/disclaimer <http://www.ukzn.ac.za/disclaimer/>_

---------------------------------------!


— axes.py2007-01-
22 18:57:58.000000000 +0200
+++ patched_axes.py2007-04-30 15:12:15.921875000 +0200
@@ -4462,7 +4462,7 @@
if width is None: width = 0.9*(bins[1]-bins[0])
if orientation == ‘horizontal’:
patches = self.barh(bins, n, height=width, left=bottom,

  •                            align=align, log=log)
    
  •                            align=align)
       elif orientation == 'vertical':**>              patches = self.bar(bins, n, width=width, bottom=bottom,
                               align=align, log=log)
    


This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/


_________________!


Matplotlib-users mailing list**> Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users****

Please find our Email Disclaimer here–>:
http://www.ukzn.ac.za/disclaimer