本文簡要介紹 python 語言中 matplotlib.pyplot.rc
的用法。
-
設置當前
rcParams
。group
是 rc 的分組,例如,對於lines.linewidth
,組是lines
,對於axes.facecolor
,組是axes
,等等。組也可以是組名稱的列表或元組,例如 (xtick
,ytick
)。kwargs
是字典屬性名稱/值對,例如:rc('lines', linewidth=2, color='r')
設置當前的
rcParams
,相當於:rcParams['lines.linewidth'] = 2 rcParams['lines.color'] = 'r'
以下別名可用於保存交互式用戶的輸入:
別名
屬性
'lw'
'linewidth'
'ls'
'linestyle'
'c'
'color'
'fc'
'facecolor'
'ec'
'edgecolor'
'mew'
'markeredgewidth'
'aa'
'antialiased'
因此,您可以將上述調用縮寫為:
rc('lines', lw=2, c='r')
請注意,您可以使用 python 的 kwargs 字典工具來存儲默認參數的字典。例如,您可以按如下方式自定義字體 rc:
font = {'family' : 'monospace', 'weight' : 'bold', 'size' : 'larger'} rc('font', **font) # pass in the font dict as kwargs
這使您可以輕鬆地在多種配置之間切換。更改後使用
matplotlib.style.use('default')
或rcdefaults()
恢複默認的rcParams
。注意
使用普通的 dict 接口可以使用類似的函數,即
rcParams.update({"lines.linewidth": 2, ...})
(但rcParams.update
不支持縮寫或分組)。
用法
matplotlib.pyplot.rc(group, **kwargs)
相關用法
- Python matplotlib rc_context用法及代碼示例
- 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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。