课程评价 (0)

请对课程作出评价:
0/300

学员评价

暂无精选评价
10分钟

path effect

  1. matplotlibpatheffects模块提供了一些函数来绘制path effect,该模块还定义了很多effect类。可以应用path effectArtist有:PatchLine2DCollection以及Text。每个Artistpath effect可以通过.set_path_effects()方法控制,其参数是一个可迭代对象,迭代的结果是AbstractPathEffect实例;也可以通过Artist构造函数的path_effects=关键字参数控制。 注意:effect类的关键字参数比如背景色、前景色等与Artist不同。因为这些effect类是更低层次的操作。
  2. 所有的effect类都继承自matplotlib.patheffects.AbstractPathEffect类。AbstractPathEffect的子类要覆盖AbstractPathEffect类的.draw_path(...)方法。 AbstractPathEffect类的构造函数有个offset关键字参数,表示effect偏移(默认为(0,0))
  3. 最简单的effectnormal effect,它是matplotlib.patheffects.Normal类。它简单的绘制Artist,不带任何effect。 如:
  import matplotlib.pyplot as plt
  import matplotlib.patheffects as path_effects
  fig = plt.figure(figsize=(5, 1.5))
  text = fig.text(0.5, 0.5, 'Hello path effects world!\nThis is the normal path effect.',
  ha='center', va='center', size=20)
  text.set_path_effects([path_effects.Normal()])
  plt.show()