Warning: Undefined variable $position in /home/pystyles/pystyle.info/public_html/wp/wp-content/themes/lionblog/functions.php on line 4897

matplotlib – x 軸、y 軸を反転させる方法について

matplotlib – x 軸、y 軸を反転させる方法について

概要

x 軸、y 軸を反転させる方法について解説します。

Advertisement

関数一覧

x 軸を反転させる

In [1]:
import numpy as np
from matplotlib import pyplot as plt

x = np.linspace(-5, 5, 100)
y = np.exp(x)

fig, ax = plt.subplots()
ax.invert_xaxis()
ax.plot(x, y)
ax.grid()

plt.show()

y 軸を反転させる

In [2]:
x = np.linspace(-5, 5, 100)
y = np.exp(x)

fig, ax = plt.subplots()
ax.invert_yaxis()
ax.plot(x, y)
ax.grid()

plt.show()