rc_configurator.context¶
-
rc_configurator.
context
(*args, mode=0, **kwargs)[source]¶ Temporarily modify the rc settings in a “with as” block.
This is used by ProPlot internally but may also be useful for power users. It was invented to prevent successive calls to
format
from constantly looking up and re-applying unchanged settings. Testing showed that these gratuitous rcParams lookups and artist updates increased runtime by seconds, even for relatively simple plots. It also resulted in overwriting previous rc changes with the default values upon subsequent calls toformat
.- Parameters
- Other Parameters
mode ({0,1,2}, optional) – The context mode. Dictates the behavior of
get
,fill
, andcategory
within a “with as” block when called withcontext=True
. The options are as follows.All settings (rcParams, rcParamsLong, and rcParamsShort) are returned, whether or not
context
has changed them.Unchanged rcParams return
None
. rcParamsLong and rcParamsShort are returned whether or notcontext
has changed them. This is used in the__init__
call toformat
. When a lookup returnsNone
,format
does not apply it.All unchanged settings return
None
. This is used during user calls toformat
.
Example
The below applies settings to axes in a specific figure using
context
.>>> import proplot as plot >>> with plot.rc.context(linewidth=2, ticklen=5): ... f, ax = plot.subplots() ... ax.plot(data)
By contrast, the below applies settings to a specific axes using
format
.>>> import proplot as plot >>> f, ax = plot.subplots() >>> ax.format(linewidth=2, ticklen=5)