Graph gains a blank space at the right hand side

Hi all,

I'm having some trouble with graphs ending up wider than I'd like. I'm
using matplotlib 0.98.5.2. If I do as follows:

import pylab
pylab.clf()
figure2 = pylab.figure(1)
axessubplot2 = pylab.subplot(111)
axessubplot2.fill_between([0, 1, 2, 3, 4, 5, 6], [0, 0, 0, 0, 0, 0,
0], [1, 1, 1, 1, 1, 0, 1], color='green')
axessubplot2.fill_between([4, 5, 6], [1, 0, 1], [1, 1, 1], color='red')
figure2.savefig('graph.png', dpi=100)

then the X-axis of the graph goes up to 7 and I get a white region at
the right-hand side, even though none of my calls have provided any
values for x>6. If I for example eliminate the first point and instead
do

import pylab
pylab.clf()
figure2 = pylab.figure(1)
axessubplot2 = pylab.subplot(111)
axessubplot2.fill_between([0, 1, 2, 3, 4, 5], [0, 0, 0, 0, 0, 0], [1,
1, 1, 1, 0, 1], color='green')
axessubplot2.fill_between([3, 4, 5], [1, 0, 1], [1, 1, 1], color='red')
figure2.savefig('graph.png', dpi=100)

then all is well and I don't get such a region.

So I guess I have two questions.
1) Is this a bug? It certainly feels like one...
2) Is there a workaround / what should I do instead?

Regards,
Geoff Bache

Try

axessubplot2.autoscale_view(tight=True)

Otherwise, you need to manually adjust xlim and ylim.

Regards,

-JJ

ยทยทยท

On Mon, Feb 22, 2010 at 11:00 AM, Geoff Bache <geoff.bache@...287...> wrote:

So I guess I have two questions.
1) Is this a bug? It certainly feels like one...
2) Is there a workaround / what should I do instead?