本文整理汇总了Python中matplotlib.patches.Polygon.update_from方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.update_from方法的具体用法?Python Polygon.update_from怎么用?Python Polygon.update_from使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.patches.Polygon
的用法示例。
在下文中一共展示了Polygon.update_from方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: uoflow_hist
# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import update_from [as 别名]
def uoflow_hist(x, low=None, high=None, axes=None, *args, **kwargs):
"""Make histogram with under-/overflow bins.
See also
--------
pyplot.hist
Parameters
----------
x : array-like
Data passed to `pyplot.hist`.
low, high : float, optional
The under-/overflow limits.
axes : optional
The matplotlib `Axes` to plot to.
hist_args : optional
Passed directly through to `pyplot.hist()`.
Returns
-------
n, bins, patches :
The return values of `pyplot.hist()`.
"""
if low is None and high is None:
warn("Calling bounded_hist without bounds.")
if kwargs.get("normed", False):
warn("Normed bounded histograms not implemented!")
axes = axes_helper(axes)
n_under = 0
n_over = 0
i_low = True
i_high = True
if low is not None:
i_low = low <= x
n_under = (~i_low).sum()
if high is not None:
i_high = x < high
n_over = (~i_high).sum()
idx = i_low & i_high
n, edges, patches = axes.hist(x[idx], *args, **kwargs)
if n_under:
width = edges[1] - edges[0]
poly = Polygon([[low-width, 0],
[low-width, n_under],
[low, n_under],
[low, 0]],
closed=False
)
poly.update_from(patches[-1])
axes.add_patch(poly)
if n_over:
width = edges[-1] - edges[-2]
poly = Polygon([[high, 0],
[high, n_over],
[high + width, n_over],
[high + width, 0]],
closed=False
)
poly.update_from(patches[-1])
axes.add_patch(poly)
return n, edges, patches