本文簡要介紹 python 語言中 matplotlib.patches.Patch.contains_point
的用法。
-
返回給定點是否在補丁內。
- 參數:
- point (浮點數,浮點數)
-
要檢查的點 (x, y),位於
self.get_transform()
的目標坐標中。這些是添加到圖形或軸的補丁的顯示坐標。 - radius 浮點數,可選
-
self.get_transform()
目標坐標中的補丁上的附加邊距。有關更多詳細信息,請參閱Path.contains_point
。
- 返回:
- bool
注意
此方法的正確使用取決於補丁的變換。孤立的補丁沒有變換。在這種情況下,麵片創建坐標和點坐標匹配。以下示例檢查圓心是否在圓內
>>> center = 0, 0 >>> c = Circle(center, radius=1) >>> c.contains_point(center) True
檢查轉換後的補丁的慣例源於該方法主要用於檢查顯示坐標(例如來自鼠標事件)是否在補丁內。如果要對數據坐標進行上述檢查,則必須先正確轉換它們:
>>> center = 0, 0 >>> c = Circle(center, radius=1) >>> plt.gca().add_patch(c) >>> transformed_center = c.get_transform().transform(center) >>> c.contains_point(transformed_center) True
用法
contains_point(point, radius=None)
相關用法
- Python matplotlib Patch.set_hatch用法及代碼示例
- Python matplotlib PatchCollection.sticky_edges用法及代碼示例
- Python matplotlib PatchCollection.set_hatch用法及代碼示例
- Python matplotlib PathCollection.set_hatch用法及代碼示例
- Python matplotlib PathCollection.legend_elements用法及代碼示例
- Python matplotlib PathCollection.sticky_edges用法及代碼示例
- Python matplotlib PolyQuadMesh.set_hatch用法及代碼示例
- Python matplotlib PolyCollection.sticky_edges用法及代碼示例
- Python matplotlib PolyCollection.set_hatch用法及代碼示例
- Python matplotlib PdfPages用法及代碼示例
- Python matplotlib PolyQuadMesh用法及代碼示例
- Python matplotlib PsfontsMap用法及代碼示例
- Python matplotlib PolyQuadMesh.sticky_edges用法及代碼示例
- Python matplotlib PickEvent用法及代碼示例
- Python matplotlib axvspan用法及代碼示例
- Python matplotlib Axes.get_legend_handles_labels用法及代碼示例
- Python matplotlib AbstractMovieWriter用法及代碼示例
- Python matplotlib triplot用法及代碼示例
- Python matplotlib StarPolygonCollection.set_hatch用法及代碼示例
- Python matplotlib Axes.hist用法及代碼示例
- Python matplotlib boxplot用法及代碼示例
- Python matplotlib subplots用法及代碼示例
- Python matplotlib InsetPosition用法及代碼示例
- Python matplotlib ToolManager.toolmanager_disconnect用法及代碼示例
- Python matplotlib Figure.set_size_inches用法及代碼示例
注:本文由純淨天空篩選整理自skytowner.com大神的英文原創作品 matplotlib.patches.Patch.contains_point。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。