matplotlib.pyplot.rc_context¶
- 
matplotlib.pyplot.rc_context(rc=None, fname=None)[源代码]¶
- 返回用于临时更改rcParams的上下文管理器。 - 参数: - rc双关语
- 要临时设置的rcParams。 
- fnamestr或path-like
- 具有Matplotlib rc设置的文件。如果两者都有 文件名 和 rc 已给定,设置来自 rc 优先考虑。 
 - 实例 - 通过dict传递显式值: - with mpl.rc_context({'interactive': False}): fig, ax = plt.subplots() ax.plot(range(3), range(3)) fig.savefig('example.png') plt.close(fig) - 从文件加载设置: - with mpl.rc_context(fname='print.rc'): plt.plot(x, y) # uses 'print.rc' 
 
 
