はじめに
matplotlibのグラフはスタイルを変えることでグラフの見た目を変えることができる。ここでは、その詳細について説明する。
解説
モジュールのインポート
適当なplotの作成
スタイルの適用
plt.style.use(‘スタイル名’)でスタイルが適用され、plotの見た目が変化する。
figを作成する前にスタイルの適用を行うことでplotに反映される。
図の見た目はスタイルを設定することで容易に変えることができる。
その例を以下に示す。
plt.style.use(‘classic’)

plt.style.use(‘fivethirtyeight’)

plt.style.use(‘tableau-colorblind10’)

plt.style.use(‘Solarize_Light2’)

plt.style.use(‘ggplot’)

スタイルを2重で設定
スタイルを2重で指定すると、両方のスタイルが混ざったスタイルになる。
ggplot + fivethirtyeight

fivethirtyeight + Solarize_Light2

Solarize_Light2 + fivethirtyeight

スタイルを指定する順序によっても見た目が変わる。
参考
Style sheets reference — Matplotlib 3.1.0 documentation
コメント