Bus errorとSegmentation faultに困ったら見るブログ

物理の研究者による日々の研究生活のメモ書きです ( python/emacs/html/Japascript/シェルスクリプト/TeX/Mac/C言語/Linux/git/tmux/R/ポケモンGO)

【matplotlib, python3】プロットの左のlabelとticksの色を変えたい

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)

ax.plot(range(10))
ax.set_xlabel('X-axis')
ax.set_ylabel('Y-axis', color="red")

ax.tick_params(axis='y', colors='red')
plt.show()

labelの色は後からでも変えられる

ax.set_ylabel('Y-axis')
ax.yaxis.label.set_color('red')

ランキング参加中です

↓クリックしていただけると嬉しいです〜