當我運行下面的代碼時,如果導入seaborn的行被註釋掉,可以在函數中設置字體大小並將其設置在整個圖中(我正在使用它一個更復雜的函數與幾個subplots和軸,並希望通用字體設置)。爲什麼seaborn會阻止我的with plt.rc_context({'font.size': fontsize,}):
工作,以及如何阻止它繼續這樣做,同時仍然能夠使用seaborn的功能? (我並不需要它的造型默認不過,如果該解決方案包括去除那些)導入seaborn停止設置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")