How to use the set_clip_path with the imshow function

Dear All,

I am a new user of python and of matplotlib, so, please excuse me if I
am asking a trivial question.

I am trying to use the funciton imshow to plot a temperature map of the
voltage levels of an electrical grid. After creating the grid data
using "meshgrid" and "griddata" functions, "imshow" works nicely and
fills up the whoe axes box.

Since, I also have the border line of the electrical grid (in the form
of a closed polygon coordinates), my next step is to clip the
temperature map using this polygon as a patch. Thus, I have created a
Path instance with the polygon coordinates, subsequently, a PathPatch
instance, say "patch".

Finally, I call the imshow function using the Artist options
"clip_on=True" and "clip_path=patch". I was expecting that imshow would
have filed up only the region inside the polygon, but imshow is still
mapping the full figure axis box, i.e., the plots with and without the
clip_path option are identical.

What am I missing or doing wrong?

Thank you very much in advance for any help,

Best wishes,

Federico

Unfortunately, clip paths are not implemented for the Agg backend. Other backends (Ps, Pdf, Svg) may work, but I haven't tried that in a while.

I've spent a few tries trying to come up with the magic Agg incantation to make this work. It's not really documented in Agg, but it should theoretically be possible. It would take someone probably to dig through the Agg source code and figure it out. Any volunteers? :wink:

Cheers,
Mike

Federico Milano wrote:

···

Dear All,

I am a new user of python and of matplotlib, so, please excuse me if I
am asking a trivial question.

I am trying to use the funciton imshow to plot a temperature map of the
voltage levels of an electrical grid. After creating the grid data
using "meshgrid" and "griddata" functions, "imshow" works nicely and
fills up the whoe axes box.

Since, I also have the border line of the electrical grid (in the form
of a closed polygon coordinates), my next step is to clip the
temperature map using this polygon as a patch. Thus, I have created a
Path instance with the polygon coordinates, subsequently, a PathPatch
instance, say "patch".

Finally, I call the imshow function using the Artist options
"clip_on=True" and "clip_path=patch". I was expecting that imshow would
have filed up only the region inside the polygon, but imshow is still
mapping the full figure axis box, i.e., the plots with and without the
clip_path option are identical.

What am I missing or doing wrong?

Thank you very much in advance for any help,

Best wishes,

Federico

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

Dear Mike,

thanks a lot for the information.

Best wishes,

Federico

Michael Droettboom wrote:

···

Unfortunately, clip paths are not implemented for the Agg backend. Other backends (Ps, Pdf, Svg) may work, but I haven't tried that in a while.

I've spent a few tries trying to come up with the magic Agg incantation to make this work. It's not really documented in Agg, but it should theoretically be possible. It would take someone probably to dig through the Agg source code and figure it out. Any volunteers? :wink:

Cheers,
Mike

Federico Milano wrote:

Dear All,

I am a new user of python and of matplotlib, so, please excuse me if I
am asking a trivial question.

I am trying to use the funciton imshow to plot a temperature map of the
voltage levels of an electrical grid. After creating the grid data
using "meshgrid" and "griddata" functions, "imshow" works nicely and
fills up the whoe axes box.

Since, I also have the border line of the electrical grid (in the form
of a closed polygon coordinates), my next step is to clip the
temperature map using this polygon as a patch. Thus, I have created a
Path instance with the polygon coordinates, subsequently, a PathPatch
instance, say "patch".

Finally, I call the imshow function using the Artist options
"clip_on=True" and "clip_path=patch". I was expecting that imshow would
have filed up only the region inside the polygon, but imshow is still
mapping the full figure axis box, i.e., the plots with and without the
clip_path option are identical.

What am I missing or doing wrong?

Thank you very much in advance for any help,

Best wishes,

Federico

-------------------------------------------------------------------------

This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options
  

This has now been fixed in SVN. See the example/pylab_examples/image_clip_path.py for usage.

Mike

Federico Milano wrote:

···

Dear Mike,

thanks a lot for the information.

Best wishes,

Federico

Michael Droettboom wrote:
  

Unfortunately, clip paths are not implemented for the Agg backend. Other backends (Ps, Pdf, Svg) may work, but I haven't tried that in a while.

I've spent a few tries trying to come up with the magic Agg incantation to make this work. It's not really documented in Agg, but it should theoretically be possible. It would take someone probably to dig through the Agg source code and figure it out. Any volunteers? :wink:

Cheers,
Mike

Federico Milano wrote:
    

Dear All,

I am a new user of python and of matplotlib, so, please excuse me if I
am asking a trivial question.

I am trying to use the funciton imshow to plot a temperature map of the
voltage levels of an electrical grid. After creating the grid data
using "meshgrid" and "griddata" functions, "imshow" works nicely and
fills up the whoe axes box.

Since, I also have the border line of the electrical grid (in the form
of a closed polygon coordinates), my next step is to clip the
temperature map using this polygon as a patch. Thus, I have created a
Path instance with the polygon coordinates, subsequently, a PathPatch
instance, say "patch".

Finally, I call the imshow function using the Artist options
"clip_on=True" and "clip_path=patch". I was expecting that imshow would
have filed up only the region inside the polygon, but imshow is still
mapping the full figure axis box, i.e., the plots with and without the
clip_path option are identical.

What am I missing or doing wrong?

Thank you very much in advance for any help,

Best wishes,

Federico

-------------------------------------------------------------------------

This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options
  
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA