Noob Q's: Filling, and centring bars in a bar chart, centring xticks and positioning text against a log y axis

Hi all,

I’m just getting started with matplotlib and am having a few problems producing a simple bar graph. The code I’m writing to produce this can be found here: http://pastebin.com/T0WA2dh8

The issues I’m having are as follows:

  • The bars in my graph do not show as filled blue after I make the the y axis logarithmic. How do I stop this from occurring.

  • Each bar needs “centring” - they are arranged to the left of where I’d like them to be currently.

  • I’d like each of the ticks on the x axis centred beneath each of the bars.

  • I’m struggling to position text neatly above each of the bars - I’ve managed to position text well horizontally but not vertically. The log scale is making it hard for me to work out where to position them.

  • I’d like numbers in normal integer form not 10 to power form on the y axis.

Also how do I label each axis?

Any help offered will be very much appreciated.

Cheers,

Tristan

2012/12/4 Tristan Strange <tristan.strange@...287...>:

Hi all,

I'm just getting started with matplotlib and am having a few problems
producing a simple bar graph. The code I'm writing to produce this can be
found here: http://pastebin.com/T0WA2dh8

The issues I'm having are as follows:

- The bars in my graph do not show as filled blue after I make the the y
axis logarithmic. How do I stop this from occurring.

Set the y scale before calling bar().

- Each bar needs "centring" - they are arranged to the left of where I'd
like them to be currently.
- I'd like each of the ticks on the x axis centred beneath each of the bars.

exp(0.1 + np.log(y))
I'm not sure I understand this. align=center might be what you want.

- I'm struggling to position text neatly above each of the bars - I've
managed to position text well horizontally but not vertically. The log scale
is making it hard for me to work out where to position them.

If you write the text at y+k, then you'll see it log(y+k)-log(y) above
the bar in the logarithmic plot. So if you want to see it h above the
bar you have to write it at exp(h + log(y)).

- I'd like numbers in normal integer form not 10 to power form on the y
axis.

I'm sure it can be done but I'm unable to help. Are you sure you want
so many zeros in the Y tick labels?

Also how do I label each axis?

xlabel(), ylabel()

Also the calls to xticks() and plot() are useless. Check this code:
http://pastebin.com/ELNV9Bea

···

Any help offered will be very much appreciated.

Cheers,
Tristan

------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

2012/12/4 Tristan Strange <tristan.strange@...287...>:
> - I'd like each of the ticks on the x axis centred beneath each of the
bars.
exp(0.1 + np.log(y))
I'm not sure I understand this. align=center might be what you want.

This is exactly what I was after.

> - I'd like numbers in normal integer form not 10 to power form on the y
> axis.

I'm sure it can be done but I'm unable to help. Are you sure you want
so many zeros in the Y tick labels?

Think you're right there actually.

Also the calls to xticks() and plot() are useless. Check this code:
http://pastebin.com/ELNV9Bea

This is exactly what I was after many thanks.

Cheers,
Tristan

···

On 4 December 2012 17:20, Goyo <goyodiaz@...287...> wrote: