LoginSignup
41
30

More than 5 years have passed since last update.

matplotlibの表示順に関する設定

Last updated at Posted at 2018-11-02

grid

gridが最前面にきて、plotに覆いかぶさることがたまにあります。
grid1.png

この場合、axisbelow(True)でgridが最背面に移動します。


##axの場合
ax.set_axisbelow(True)

##rcParamsの場合
plt.rcParams['axes.axisbelow'] = True

grid2.png

plotの表示順

plotの表示順はzorderで設定できます。
zorderとは平面上のxy軸に対して、奥行きのz軸に関する設定です。
値を大きくすることでプロットを手前にもってくることができます。

線のzorderが1, 丸のzorderが2

plt.plot(x, y, 'r', zorder=1, lw=3)
plt.scatter(x, y, s=120, zorder=2)

zorder1.png

線のzorderが2, 丸のzorderが1

plt.plot(x, y, 'r', zorder=2, lw=3)
plt.scatter(x, y, s=120, zorder=1)

zorder2.png

参考

41
30
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
41
30