barh Chart - Not lining up

The following, with svn mpl, works. If it doesn't work for you, make
sure to upgrade your matplotlib; note the use of "align" which is a
fairly recent addition to mpl

    val = [2,5,3,6,3] # the bar lengths
    pos = arange(5)+.5 # the bar centers on the y axis
    
    p1 = figure.gca().barh(pos,val, align='center')
    ax = figure.gca()
    ax.set_yticks(pos)
    ax.set_yticklabels(('Tom', 'Dick', 'Harry', 'Slim', 'Jim'))
    ax.set_xlabel('Perfomance')
    ax.set_title('How fast do you want to go today?')
    canvas=FigureCanvasAgg(figure)

JDH

···

On 8/3/06, John Hunter <jdhunter@...4...> > wrote:

    >> >>>>> "Gregory" == Gregory Pi?ero <gregpinero@...287...>
    >> writes:
    > bar centers on the y axis p1 = figure.gca().barh(pos,val)
    > figure.gca().set_yticks(pos)
    > figure.gca().set_yticklabels(('Tom', 'Dick', 'Harry',
    > 'Slim', 'Jim')) figure.gca().set_xlabel('Perfomance')
    > figure.gca().set_title('How fast do you want to go
    > today?') canvas=FigureCanvasAgg(figure) return canvas
    >>
    > I changed the code to above but it still gives a similair
    > result.

So all you changed was to add in align='center' ? I assume me using
figure.gca() is equivalent to your use of ax?

Is it hard to upgrade to the latest version from svn? Any directions?

-Greg

···

On 8/3/06, John Hunter <jdhunter@...4...> wrote:

The following, with svn mpl, works. If it doesn't work for you, make
sure to upgrade your matplotlib; note the use of "align" which is a
fairly recent addition to mpl

    val = [2,5,3,6,3] # the bar lengths
    pos = arange(5)+.5 # the bar centers on the y axis

    p1 = figure.gca().barh(pos,val, align='center')
    ax = figure.gca()
    ax.set_yticks(pos)
    ax.set_yticklabels(('Tom', 'Dick', 'Harry', 'Slim', 'Jim'))
    ax.set_xlabel('Perfomance')
    ax.set_title('How fast do you want to go today?')
    canvas=FigureCanvasAgg(figure)

So all you changed was to add in align='center' ? I assume me using
figure.gca() is equivalent to your use of ax?

Yes, gca() is "get the current axes object".

Is it hard to upgrade to the latest version from svn? Any directions?

[From
'http://projects.scipy.org/neuroimaging/ni/wiki/DevelopmentInstallFedora’]

svn co matplotlib download | SourceForge.net
matplotlib-trunk
cd matplotlib-trunk
python setup.py build
sudo python setup.py install
cd ..

But Greg, if it's only for that, try to put an empty label in front of the
others:
figure.gca().set_yticklabels(('', 'Tom', 'Dick', 'Harry', 'Slim', 'Jim'))
That might do the trick

···

On Thursday 03 August 2006 17:44, Gregory Piñero wrote:

Another question, why are there only four bars showing up when I have
5 values and 5 labels?

No, that didn't work. Did the barh just not work well in my version?

···

On 8/3/06, PGM <pgmdevlist@...287...> wrote:

But Greg, if it's only for that, try to put an empty label in front of the
others:
figure.gca().set_yticklabels(('', 'Tom', 'Dick', 'Harry', 'Slim', 'Jim'))
That might do the trick

???
On my machine, (matplotlib.__version__ = '0.87.4'), the script you posted
around 5PM (EST) works OK, five bars, five labels nicely placed (once
prepended with a fake one )...

···

On Thursday 03 August 2006 20:41, Gregory Piñero wrote:

Another question, why are there only four bars showing up when I have
5 values and 5 labels?