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
, andcategory
within a “with as” block when called withcontext=True
.The options are as follows:
mode=0
: Matplotlib’src_matplotlib
settings and proplot’src_proplot
settings are all returned, whether or not they are local to the “with as” block.mode=1
: Matplotlib’src_matplotlib
settings 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_matplotlib
settings and proplot’src_proplot
settings 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
1
is used whenformat
is called during axes instantiation, and mode2
is used whenformat
is manually called by users. The latter prevents successive calls toformat
from 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 usescontext
internally.>>> import proplot as pplt >>> fig, ax = pplt.subplots() >>> ax.format(ticklen=5, metalinewidth=2)