imshow and projection axes

Dear all,

in matplotlib version 0.99.0 when drawing images with imshow into figures with
hammer or aitoff axes the images are clipped to the axes. Now this has changed
in and the images are drawn also outside the axes (version 0.99.3) or not
drawn at all (version 1.0.0). How can I clip them again to the axes?

Best regards,

Tobias

Which backend are you using? Can you provide a short script that
reproduces the bug?

Mike

···

http://p.sf.net/sfu/sprint-com-first


Matplotlib-users@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hi,

Which backend are you using?

I tried this with GTKAgg and Qt4Agg, its was working with 0.99.0 and 0.99.1 on
Debian/Squeeze and 0.99.0 on Scientific Linux 5. I first noticed this with
0.99.3 on Debian/Squeeze, but it is the same with with 1.0.0 on Debian/Squeeze
and Scientific Linux 5.

Can you provide a short script that
reproduces the bug?

This script reproduces the behaviour:

import pylab
from math import *

d = [[1,2],[3,4]]

f = pylab.figure()
pylab.subplot(111, projection='hammer')

pylab.imshow(d, extent=(-pi,pi,-pi/2,pi/2))
f.show()

It creates the following plot in version 0.99.0
http://web.physik.rwth-aachen.de/~winchen/mpl_0990.png

and in version 0.99.3
http://web.physik.rwth-aachen.de/~winchen/mpl_0993.png

Best regards,

Tobias

···

On Thursday 22 July 2010 Michael Droettboom wrote:

I’ve traced this back to revision 7867:

http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/branches/v0_99_maint/lib/matplotlib/axes.py?r1=7867&r2=7866&pathrev=7867

Andrew: I’m sure that change is there for a good reason – do you
remember what it was? I don’t just want to revert it. Interestingly,
get_clip_on() is True by default, and I’m not sure in what case it’s
set to False in this context.

Mike

···

http://web.physik.rwth-aachen.de/~winchen/mpl_0990.pnghttp://web.physik.rwth-aachen.de/~winchen/mpl_0993.pnghttp://p.sf.net/sfu/sprint-com-first


Matplotlib-users@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/matplotlib-users

-- Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA

BTW – I think a possible fix may be to do:

    if not im.get_clip_path():

        im.set_clip_path(self.patch)

Mike

···

http://web.physik.rwth-aachen.de/~winchen/mpl_0990.pnghttp://web.physik.rwth-aachen.de/~winchen/mpl_0993.pnghttp://p.sf.net/sfu/sprint-com-first


Matplotlib-users@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/matplotlib-users

-- Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA
-- Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA

Hi Mike,

I don’t remember this. But looking back at the commit logs, I see
“imshow: only apply axes patch clipping if image doesn’t clip itself”
as the original commit message and then a few minutes later I committed
the test
test_imshow_clip() in text_axes.py. It looks like I was responding to a
bug and/or patch submission. As long as that test still passes, I think
it’s OK to check in your fix. We could also add Tobias’ script as
another test.

-Andrew

···

On 7/23/10 3:16 PM, Michael Droettboom wrote:

I’ve traced this back to revision 7867:

http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/branches/v0_99_maint/lib/matplotlib/axes.py?r1=7867&r2=7866&pathrev=7867

Andrew: I’m sure that change is there for a good reason – do you
remember what it was? I don’t just want to revert it. Interestingly,
get_clip_on() is True by default, and I’m not sure in what case it’s
set to False in this context.

Hi, thank you for your quick answers which pointed me to a solution:

setting clip_on=False solves the problem:

pylab.imshow(d, extent=(-pi,pi,-pi/2,pi/2), clip_on=False)

However, for me it feels not very intuitive to write clip_on=False to
activate the desired clipping.

Tobias