直接將線條添加到圖形#

您可以將像是 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 產生圖庫