Configurator.context¶
- Configurator.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 offind,fill, andcategorywithin a “with as” block when called withcontext=True.The options are as follows:
mode=0: Matplotlib’src_matplotlibsettings and proplot’src_proplotsettings are all returned, whether or not they are local to the “with as” block.mode=1: Matplotlib’src_matplotlibsettings are only returned if they are local to the “with as” block. For example, ifrc['axes.titlesize']was passed tocontext, thenpplt.rc.find('axes.titlesize', context=True)will return this value, butpplt.rc.find('axes.titleweight', context=True)will returnNone. This is used internally when instantiating axes.mode=2: Matplotlib’src_matplotlibsettings and proplot’src_proplotsettings are only returned if they are local to the “with as” block. This is used internally when formatting axes.
Note
Context “modes” are primarily used internally but may also be useful for power users. Mode
1is used whenformatis called during axes instantiation, and mode2is used whenformatis manually called by users. The latter prevents successive calls toformatfrom constantly looking up and re-applying unchanged settings and significantly increasing the runtime.Example
The below applies settings to axes in a specific figure using
context.>>> import proplot as pplt >>> with pplt.rc.context(ticklen=5, metalinewidth=2): >>> 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(ticklen=5, metalinewidth=2)