bug or feature?

Hi,

I have some problem with this kind of script:

#!/usr/bin/env python
import numpy
import numpy.random
import pylab

a = numpy.random.rand(10,10)
pylab.matshow(a)
pylab.colorbar()

pylab.figure(figsize=(4.8,8),dpi=100)
pylab.imshow(a,aspect='equal',interpolation='nearest')
pylab.colorbar()

pylab.show()

The second figure is not good (at least for my point of view). I was expecting
that the colorbar will have the same size than the image, even if aspect is
set on equal or a number. Perhaps there are a simple solution for this that I
didn't find.

Thanks

N.

What you see is a design limitation rather than a bug or feature. One easy workaround is to use the shrink kwarg. See examples/contour_demo.py. Another approach is to create the axes object you want for the colorbar manually, as in examples/multi_image.py and examples/subplots_adjust.py.

Eric

humufr@...136... wrote:

ยทยทยท

Hi,

I have some problem with this kind of script:

#!/usr/bin/env python
import numpy
import numpy.random
import pylab

a = numpy.random.rand(10,10)
pylab.matshow(a)
pylab.colorbar()

pylab.figure(figsize=(4.8,8),dpi=100)
pylab.imshow(a,aspect='equal',interpolation='nearest')
pylab.colorbar()

pylab.show()

The second figure is not good (at least for my point of view). I was expecting that the colorbar will have the same size than the image, even if aspect is set on equal or a number. Perhaps there are a simple solution for this that I didn't find.