Hi,

I'm trying to draw a bar chart according to
http://matplotlib.sourceforge.net/examples/api/barchart_demo.html, and I'm
having to difficulties :

 - when the first bar has a zero height, it is no taken into account during
the axis limits calculation and is not visible

 - texts objects can exceed chart area and collide with the chart title.

Is there a way to calculate the axis limit to use to include all texts
objects into the chart area ?

Here is the code I used :

[code]
#!/usr/bin/env python

import numpy as np
import matplotlib.pyplot as plt

menMeans = [    0.        ,   998.        ,  1210.        ,  1449.       ,
        1496.        ,  1493.        ,  1593.40002441,  1517.5       ]

ind = np.arange(len(menMeans))  # the x locations for the groups
width = 0.8            # the width of the bars

fig = plt.figure()
ax = fig.add_subplot(111)
rects1 = ax.bar(ind, menMeans, width, color='r')

# add some
ax.set_ylabel('Scores')
ax.set_title('A very very long title for testing.')

def autolabel(rects):
    # attach some text labels
    for rect in rects:
        height = rect.get_height()
        ax.text(rect.get_x()+rect.get_width()/2., 1.05*height,
'%d'%int(height),
                ha='center', va='bottom')

autolabel(rects1)

plt.show()
[/code]

Best regards,

-- 
LB
------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to