备注
Go to the end 下载完整示例代码.
直接向图像添加线条#
您可以将诸如 Line2D 的艺术家直接添加到图像中.这通常对于可视化结构很有用.
import matplotlib.pyplot as plt
import matplotlib.lines as lines
fig, axs = plt.subplots(2, 2, gridspec_kw={'hspace': 0.4, 'wspace': 0.4})
fig.add_artist(lines.Line2D([0, 1], [0.47, 0.47], linewidth=3))
fig.add_artist(lines.Line2D([0.5, 0.5], [1, 0], linewidth=3))
plt.show()

参考
以下函数,方法,类和模块的用法在本例中显示:
matplotlib.pyplot.figurematplotlib.linesmatplotlib.lines.Line2D