はじめに
matplotlibのimshowで画像を任意の形状で切り取って表示する方法について解説する。
コード

解説
モジュールのインポート
画像の読み込み
この画像を読み込む。

円形に切り取る
set_clip_path(patch)のpatchに任意の図形をpatchesで設定する。ここでは、中心の座標が540, 520), 半径が320の円で切り取っている。
正方形の場合

楕円の場合

参考
matplotlib.pyplot.imshow — Matplotlib 3.1.2 documentation

[matplotlib animation] 23. 胴体が伸びる犬
matplotlib FuncAnimationによる図形のアニメーション(胴体が伸びる犬)
コメント