本文簡要介紹 python 語言中 matplotlib.transforms.Bbox
的用法。
-
基礎:
BboxBase
一個可變的邊界框。
例子
從已知邊界創建
默認構造函數采用邊界 "points"
[[xmin, ymin], [xmax, ymax]]
。>>> Bbox([[1, 1], [3, 7]]) Bbox([[1.0, 1.0], [3.0, 7.0]])
或者,可以從展平的點數組創建 Bbox,即所謂的 "extents"
(xmin, ymin, xmax, ymax)
>>> Bbox.from_extents(1, 1, 3, 7) Bbox([[1.0, 1.0], [3.0, 7.0]])
或來自 "bounds"
(xmin, ymin, width, height)
。>>> Bbox.from_bounds(1, 1, 2, 6) Bbox([[1.0, 1.0], [3.0, 7.0]])
從點集合創建
用於累加Bboxs的"empty"對象是null bbox,它是一個空集的stand-in。
>>> Bbox.null() Bbox([[inf, inf], [-inf, -inf]])
向空 bbox 添加點將為您提供這些點的 bbox。
>>> box = Bbox.null() >>> box.update_from_data_xy([[1, 1]]) >>> box Bbox([[1.0, 1.0], [1.0, 1.0]]) >>> box.update_from_data_xy([[2, 3], [3, 2]], ignore=False) >>> box Bbox([[1.0, 1.0], [3.0, 3.0]])
設置
ignore=True
相當於從一個空bbox 重新開始。>>> box.update_from_data_xy([[1, 1]], ignore=True) >>> box Bbox([[1.0, 1.0], [1.0, 1.0]])
警告建議始終顯式指定
ignore
。如果沒有,ignore
的默認值可以隨時通過有權訪問 Bbox 的代碼進行更改,例如使用方法ignore
。``null`` bbox 的屬性
注意Bbox.null()
當前的行為可能會令人驚訝,因為它不具有 "empty set" 的所有屬性,因此在數學意義上的行為不像 "zero" 對象。我們將來可能會改變這一點(有一個棄用期)。空 bbox 是交叉點的標識
>>> Bbox.intersection(Bbox([[1, 1], [3, 7]]), Bbox.null()) Bbox([[1.0, 1.0], [3.0, 7.0]])
除了它本身,它返回完整的空間。
>>> Bbox.intersection(Bbox.null(), Bbox.null()) Bbox([[-inf, -inf], [inf, inf]])
包含 null 的聯合將始終返回完整空間(而不是其他集合!)
>>> Bbox.union([Bbox([[0, 0], [0, 0]]), Bbox.null()]) Bbox([[-inf, -inf], [inf, inf]])
- 參數:
- points numpy.ndarray
-
[[x0, y0], [x1, y1]]
形式的 (2, 2) 數組。
用法
class matplotlib.transforms.Bbox(points, **kwargs)
相關用法
- Python matplotlib BrokenBarHCollection.set_hatch用法及代碼示例
- Python matplotlib BrokenBarHCollection.sticky_edges用法及代碼示例
- Python matplotlib Barbs用法及代碼示例
- Python matplotlib BoxStyle用法及代碼示例
- 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用法及代碼示例
- Python matplotlib figlegend用法及代碼示例
- Python matplotlib Axes.step用法及代碼示例
- Python matplotlib Axes.contour用法及代碼示例
- Python matplotlib LassoSelector用法及代碼示例
- Python matplotlib Axes.plot用法及代碼示例
- Python matplotlib Axes.semilogx用法及代碼示例
- Python matplotlib Axes.semilogy用法及代碼示例
- Python matplotlib MovieWriterRegistry.register用法及代碼示例
- Python matplotlib PolyQuadMesh.set_hatch用法及代碼示例
- Python matplotlib warn_deprecated用法及代碼示例
注:本文由純淨天空篩選整理自skytowner.com大神的英文原創作品 matplotlib.transforms.Bbox。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。