I tried to execute the following code:

http://matplotlib.org/faq/howto_faq.html#test-whether-a-point-is-inside-a-polygon

However I get errors I describe here:

http://stackoverflow.com/questions/16452509/matplotlib-pnpoly-example-results-in-error

>>>import numpy as np
>>>import matplotlib.nxutils as nx
>>>verts = np.array([ [0,0], [0, 1], [1, 1], [1,0]], float)
>>>nx.pnpoly(0.5, 0.5, verts)

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Python27\lib\site-packages\matplotlib\nxutils.py", line 26, in
pnpoly
    return p.contains_point(x, y)
  File "C:\Python27\lib\site-packages\matplotlib\path.py", line 289, in
contains_point
    transform = transform.frozen()
AttributeError: 'float' object has no attribute 'frozen'

>>>nx.pnpoly(0.5, 1.5, verts)

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Python27\lib\site-packages\matplotlib\nxutils.py", line 26, in
pnpoly
    return p.contains_point(x, y)
  File "C:\Python27\lib\site-packages\matplotlib\path.py", line 289, in
contains_point
    transform = transform.frozen()
AttributeError: 'float' object has no attribute 'frozen'

Apparently, nxutils is deprecated, which to me means it should still work
but a user on stackoverflow pointed out that there may be some code rot.
That said, the documentation on matplotlib.path.Path.contains_point is weak
(see below). Does anyone have an example of how I can do the exact same
thing in the code in the howto_faq but using the suggested function
(contains_point)?

http://matplotlib.org/1.2.1/api/path_api.html?highlight=contains_point#matplotlib.path.Path.contains_point

contains_point(point, transform=None, radius=0.0)

    Returns True if the path contains the given point.
    If transform is not None, the path will be transformed before performing
the test.
    radius allows the path to be made slightly larger or smaller.

contains_points(points, transform=None, radius=0.0)

    Returns a bool array which is True if the path contains the
corresponding point.
    If transform is not None, the path will be transformed before performing
the test.
    radius allows the path to be made slightly larger or smaller.






--
View this message in context: 
http://matplotlib.1069221.n5.nabble.com/re-matplotlib-pnpoly-example-results-in-error-tp41028.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to