当我运行下面的代码时,如果导入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")