###前提・実現したいこと
Pythonのmatplotlibについて、フォントに関する質問があります。x軸とy軸のラベルフォントを「sans-serif」に設定した上で一部の文字を斜体にしたいのですがうまくいきません。フォントを「sans-serif」に変更することはできたのですが、斜体にしようとするとフォントが「Times New Roman」になってしまいます。
詳しい方いらっしゃいましたら、教えていただきたく思います。
よろしくお願いいたします。
###発生している問題・エラーメッセージ
具体的には、下のような図で、y軸ラベルの大文字のPとx軸ラベルのギリシャ文字のΦをフォントを「sans-serif」に保ったまま斜体にしたいのですが、
\it{}を使うと以下の図のようにフォントが「Times New Roman」になってしまいます。
Unicodeも試してみましたが、文字化けがあったり、斜体にならなかったりとでうまくいきません
###該当のソースコード
Python
1#以下がフォントを「sans-serif」にしただけのもの 2from matplotlib import pyplot as plt 3import math 4 5plt.rcParams['font.family'] = 'sans-serif' 6 7x=[] 8y=[] 9 10i=0 11while i<=180: 12 x.append(i) 13 y.append(1-math.exp(-i/45)) 14 i+=1 15 16plt.plot(x, y) 17plt.xlabel("Angle "+r"$\mathregular{\phi}$ "+"$\mathregular{[\degree]}$", fontsize=20) # x軸のタイトル 18plt.ylabel("Probability P"+r"$\mathregular{_{SW}}$", fontsize=20) # y軸 19 20plt.show()
Python
1#以下が一部斜体を試みたもの 2from matplotlib import pyplot as plt 3import math 4 5plt.rcParams['font.family'] = 'sans-serif' 6 7x=[] 8y=[] 9 10i=0 11while i<=180: 12 x.append(i) 13 y.append(1-math.exp(-i/45)) 14 i+=1 15 16plt.plot(x, y) 17plt.xlabel("Angle "+r"$\mathregular{\it{\phi}}$ "+"$\mathregular{[\degree]}$", fontsize=20) # x軸のタイトル 18plt.ylabel("Probability "+r"$\mathregular{\itP}$"+r"$\mathregular{_{SW}}$", fontsize=20) # y軸 19 20plt.show()
###試したこと
上記のように「\it」を使う以外では、
「\mathregular」の部分を「\mathsf」に変更
->斜体にならない、またはフォントが変わってしまう。
Unicodeの斜体文字を使用
->斜体にならない。
という状態で、うまくいきません。
###補足情報(言語/FW/ツール等のバージョンなど)
OS:Windows10
Ver:Python3.5

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。