軸線樣式#

此範例顯示軸樣式的一些組態。

注意:對於新使用者來說,mpl_toolkits.axisartist 軸類別可能會令人困惑。如果唯一目的是在軸末端取得箭頭,請查看具有箭頭的置中軸脊範例。

demo axisline style
import matplotlib.pyplot as plt
import numpy as np

from mpl_toolkits.axisartist.axislines import AxesZero

fig = plt.figure()
ax = fig.add_subplot(axes_class=AxesZero)

for direction in ["xzero", "yzero"]:
    # adds arrows at the ends of each axis
    ax.axis[direction].set_axisline_style("-|>")

    # adds X and Y-axis from the origin
    ax.axis[direction].set_visible(True)

for direction in ["left", "right", "bottom", "top"]:
    # hides borders
    ax.axis[direction].set_visible(False)

x = np.linspace(-0.5, 1., 100)
ax.plot(x, np.sin(x*np.pi))

plt.show()

由 Sphinx-Gallery 產生之圖庫