RcConfigurator.context¶
- RcConfigurator.context(*args, mode=0, file=None, **kwargs)[source]¶
Temporarily modify the rc settings in a “with as” block.
- Parameters
- Other Parameters
mode ({0, 1, 2}, optional) – The context mode. Dictates the behavior of
get,fill, andcategorywithin a “with as” block when called withcontext=True.The options are as follows:
Matplotlib’s builtin settings and ProPlot’s added settings are all returned, whether or not
contexthas changed them.Unchanged matplotlib settings return
None. All of ProPlot’s added settings are returned whether or notcontexthas changed them. This is used in the__init__call toformat. When a lookup returnsNone,formatdoes not apply it.All unchanged settings return
None. This is used during user calls toformat.
Note
This is used by ProPlot internally but may also be useful for power users. It was invented to prevent successive calls to
formatfrom constantly looking up and re-applying unchanged settings. These gratuitous lookups increased runtime significantly, and resulted in successive calls toformatoverwriting the previous calls.Example
The below applies settings to axes in a specific figure using
context.>>> import proplot as pplt >>> with pplt.rc.context(linewidth=2, ticklen=5): >>> fig, ax = pplt.subplots() >>> ax.plot(data)
The below applies settings to a specific axes using
format, which usescontextinternally.>>> import proplot as pplt >>> fig, ax = pplt.subplots() >>> ax.format(linewidth=2, ticklen=5)