rc_configurator.context¶
-
rc_configurator.
context
(*args, mode=0, **kwargs)[source]¶ Temporarily modifies settings in a
with...as
block, used by ProPlot internally but may also be useful for power users.This function 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.- Parameters
*args – Dictionaries of setting names and values.
**kwargs – Setting names and values passed as keyword arguments.
- Other Parameters
mode ({0,1,2}, optional) – The
__getitem__
mode. Dictates the behavior of therc
object within awith...as
block when settings are requested with e.g.rc.setting
. If you are usingcontext
manually, themode
is automatically set to0
– other input is ignored. Internally, ProPlot uses all of the three available modes.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 setting lookup returnsNone
,format
does not apply it.All unchanged settings return
None
. This is used during user calls toformat
.
Example
>>> import proplot as plot >>> with plot.rc.context(linewidth=2, ticklen=5): ... f, ax = plot.subplots() ... ax.plot(data)