直接向图形添加线条#

你可以直接将艺术家(如 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()
fig x

参考文献

以下函数、方法、类和模块的使用在本示例中展示:

由 Sphinx-Gallery 生成的图库