Clipping

All,

I'm looking at:

http://matplotlib.sourceforge.net/examples/api/clippath_demo.html

But I cannot figure out:

patch=patches.Circle((300, 300), radius=100)

Where precisely is (300,300)?

D.

I believe it's in window coordinates (pixels), with 0,0 being the lower left.

Ryan

···

On Wed, Feb 17, 2010 at 6:44 PM, David Arnold <dwarnold45@...2108...> wrote:

All,

I'm looking at:

http://matplotlib.sourceforge.net/examples/api/clippath_demo.html

But I cannot figure out:

patch=patches.Circle((300, 300), radius=100)

Where precisely is (300,300)?

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

The coordinates for Circle (and all patches) are in data coordinates. So the (300, 300) is relative to the values in the data itself. When adding a patch directly to a plot, however, the limits may not automatically update, so you may need to call axes.set_xlim or axes.set_ylim to adjust them to make the circle visible.

Mike

Ryan May wrote:

···

On Wed, Feb 17, 2010 at 6:44 PM, David Arnold <dwarnold45@...2108...> wrote:
  

All,

I'm looking at:

http://matplotlib.sourceforge.net/examples/api/clippath_demo.html

But I cannot figure out:

patch=patches.Circle((300, 300), radius=100)

Where precisely is (300,300)?
    
I believe it's in window coordinates (pixels), with 0,0 being the lower left.

Ryan

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

In this example, though, he is not adding the Circle to the Axes via
add_patch (so the transData transform is not set).

Rather, he is using it to set the clip path

  http://matplotlib.sourceforge.net/examples/api/clippath_demo.html

So I think Ryan's answer is correct.

But David, if you want the clippath to be in data coordinates, you can
set the transform yourself

  patch = patches.Circle((300,300), radius=100, transform=ax.transData)

See the transformations tutorial for more about the coordinate systems
and transformations

  http://matplotlib.sourceforge.net/users/transforms_tutorial.html

JDH

···

On Mon, Feb 22, 2010 at 10:11 AM, Michael Droettboom <mdroe@...86...> wrote:

The coordinates for Circle (and all patches) are in data coordinates.
So the (300, 300) is relative to the values in the data itself. When
adding a patch directly to a plot, however, the limits may not
automatically update, so you may need to call axes.set_xlim or
axes.set_ylim to adjust them to make the circle visible.