path effect
4. 我们可以在基于Path
的Artist
上应用drop-shadow effect
(下沉效果)。如可以在filled patch Artist
上应用matplotlib.patheffects.SimplePatchShadow
,在line patch Artist
上应用matplotlib.patheffects.SimpleLineShadow
。
你可以通过path_effects=[path_effects.with*()]
来指定path_effects
参数,或者直接通过path_effects=[path_effects.SimpleLineShadow(),path_effects.Normal()]
来指定path_effects
参数。
- 前者会自动地在
normal effect
后跟随指定的effect
- 后者会显式的指定
effect
5.Strok effect
可以用于制作出stand-out effect
(突出效果)。
6. PathPatchEffect
是一个通用的path effect
类。如果对某个PathPatch
设置了PathPatchEffect
,则该effect
的.draw_path(...)
方法执行的是由初始PathPatch
计算的得到的一个新的PathPatch
。
与一般的effect
类不同,PathPatchEffect
类的关键字参数是与PathPatch
一致的,因为除了offset
关键字参数外,其他的任何关键字参数都会传递给PathPatch
构造函数。如:
import matplotlib.pyplot as plt import matplotlib.patheffects as path_effects fig = plt.figure(figsize=(8, 1)) t = fig.text(0.02, 0.5, 'Hatch shadow', fontsize=75, weight=1000, va='center') t.set_path_effects([path_effects.PathPatchEffect(offset=(4, -4), hatch='xxxx', facecolor='gray'), path_effects.PathPatchEffect(edgecolor='white', linewidth=1.1, facecolor='black')]) plt.show()
学员评价