本文簡要介紹 python 語言中 matplotlib.pyplot.rc_context
的用法。
-
返回用於臨時更改 rcParams 的上下文管理器。
rcParams["backend"]
不會被上下文管理器重置。通過上下文管理器調用和上下文主體中的 rcParams 更改將在上下文退出時重置。
- 參數:
- rc dict
-
要臨時設置的 rcParams。
- fname str 或 path-like
-
具有 Matplotlib rc 設置的文件。如果同時給出
fname
和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'
在上下文主體中設置:
with mpl.rc_context(): # will be reset mpl.rcParams['lines.linewidth'] = 5 plt.plot(x, y)
用法
matplotlib.pyplot.rc_context(rc=None, fname=None)
相關用法
- Python matplotlib rc用法及代碼示例
- Python matplotlib register_cmap用法及代碼示例
- Python matplotlib rgrids用法及代碼示例
- Python matplotlib rename_parameter用法及代碼示例
- Python matplotlib relativedelta用法及代碼示例
- Python matplotlib axvspan用法及代碼示例
- Python matplotlib Axes.get_legend_handles_labels用法及代碼示例
- Python matplotlib AbstractMovieWriter用法及代碼示例
- Python matplotlib triplot用法及代碼示例
- Python matplotlib StarPolygonCollection.set_hatch用法及代碼示例
- Python matplotlib Axes.hist用法及代碼示例
- Python matplotlib boxplot用法及代碼示例
- Python matplotlib subplots用法及代碼示例
- Python matplotlib InsetPosition用法及代碼示例
- Python matplotlib ToolManager.toolmanager_disconnect用法及代碼示例
- Python matplotlib Figure.set_size_inches用法及代碼示例
- Python matplotlib figlegend用法及代碼示例
- Python matplotlib Axes.step用法及代碼示例
- Python matplotlib Axes.contour用法及代碼示例
- Python matplotlib LassoSelector用法及代碼示例
- Python matplotlib BrokenBarHCollection.set_hatch用法及代碼示例
- Python matplotlib Axes.plot用法及代碼示例
- Python matplotlib Axes.semilogx用法及代碼示例
- Python matplotlib Axes.semilogy用法及代碼示例
- Python matplotlib MovieWriterRegistry.register用法及代碼示例
注:本文由純淨天空篩選整理自skytowner.com大神的英文原創作品 matplotlib.pyplot.rc_context。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。