以下のコードを実行すると、seabornを読み込む行がコメントアウトされていて、関数内でfontsizeを設定してプロット全体に設定できますいくつかのサブプロットと軸を持つより複雑な関数で、普遍的なフォント設定が必要です)。なぜシーボーンは私のwith plt.rc_context({'font.size': fontsize,}):
を止めているのですか?それでも、シーボーンの機能を利用できる間に、私はそれを止めることができますか? (私は解決策がそれらを除去することを含む場合、それはかかわらず、デフォルトのスタイリングだ必要はありません)seabornをインポートすると、set rc_paramsが動作しなくなる
import matplotlib.pyplot as plt
import numpy as np
import seaborn
def plotthing(x, y, fontsize=8):
with plt.rc_context({'font.size': fontsize,}):
fig, ax = plt.subplots()
ax.plot(x, y)
ax.set_xlabel("x")
ax.set_xlabel("y")
return fig, ax
x = np.arange(0, 10)
y = 2*x**2
fig, ax = plotthing(x, y, fontsize=2)
fig.savefig("test.pdf")