當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python matplotlib Transform.__sub__用法及代碼示例

本文簡要介紹 python 語言中 matplotlib.transforms.Transform.__sub__ 的用法。

用法

__sub__(other)

other 的倒數編寫 self ,如果有的話,取消相同的項:

# In general:
A - B == A + B.inverted()
# (but see note regarding frozen transforms below).

# If A "ends with" B (i.e. A == A' + B for some A') we can cancel
# out B:
(A' + B) - B == A'

# Likewise, if B "starts with" A (B = A + B'), we can cancel out A:
A - (A + B') == B'.inverted() == B'^-1

取消(而不是天真地返回 A + B.inverted() )很重要,原因有很多:

  • 它在計算 B 的逆時避免了浮點不準確性:B - B 保證完全抵消(導致恒等變換),而 B + B.inverted() 可能相差很小的 epsilon。

  • B.inverted() 總是返回一個凍結的變換:如果一個計算 A + B + B.inverted() 並且後來發生了變異 B ,那麽 B.inverted() 將不會被更新並且最後兩個術語將不再抵消;另一方麵,即使 B 發生突變,A + B - B 也將始終等於 A

相關用法


注:本文由純淨天空篩選整理自skytowner.com大神的英文原創作品 matplotlib.transforms.Transform.__sub__。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。