Bases: MutableMapping
, dict
A dictionary-like class for managing matplotlib settings stored in rc_matplotlib
and ultraplot settings stored in rc_ultraplot
. This class is instantiated as the rc
object on import. See the user guide for details.
Attributes Summary
A dictionary of settings that have changed from the ultraplot defaults.
Methods Summary
category
(cat, *[, trimcat, context])
Return a dictionary of settings beginning with the substring cat + '.'
.
context
(*args[, mode, file])
Temporarily modify the rc settings in a "with as" block.
fill
(props, *[, context])
Return a dictionary filled with settings whose names match the string values in the input dictionary.
find
(key, *[, context])
Return a single setting.
load
(path)
Load settings from the specified file.
load_file
(*[, new_obj, message])
Return locations of files named ultraplotrc
in this directory and in parent directories.
local_folders
([subfolder])
Return locations of folders named ultraplot_cmaps
, ultraplot_cycles
, ultraplot_colors
, and ultraplot_fonts
in this directory and in parent directories.
reset
([local, user, default])
Reset the configurator to its initial state.
save
([path, user, comment, backup, description])
Save the current settings to a ultraplotrc
file.
update
(*args, **kwargs)
Update several settings at once.
Return location of the default ultraplotrc file.
user_folder
([subfolder])
Return location of the default ultraplot folder.
Attributes Documentation
A dictionary of settings that have changed from the ultraplot defaults.
Methods Documentation
Return a dictionary of settings beginning with the substring cat + '.'
. Optionally limit the search to the context level.
Temporarily modify the rc settings in a “with as” block.
mode ({0, 1, 2}
, optional) – The context mode. Dictates the behavior of find
, fill
, and category
within a “with as” block when called with context=True
.
The options are as follows:
mode=0
: Matplotlib’s rc_matplotlib
settings and ultraplot’s rc_ultraplot
settings are all returned, whether or not they are local to the “with as” block.
mode=1
: Matplotlib’s rc_matplotlib
settings are only returned if they are local to the “with as” block. For example, if rc['axes.titlesize']
was passed to context
, then uplt.rc.find('axes.titlesize', context=True)
will return this value, but uplt.rc.find('axes.titleweight', context=True)
will return None
. This is used internally when instantiating axes.
mode=2
: Matplotlib’s rc_matplotlib
settings and ultraplot’s rc_ultraplot
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 when format
is called during axes instantiation, and mode 2
is used when format
is manually called by users. The latter prevents successive calls to format
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 ultraplot as uplt >>> with uplt.rc.context(ticklen=5, metalinewidth=2): >>> fig, ax = uplt.subplots() >>> ax.plot(data)
The below applies settings to a specific axes using format
, which uses context
internally.
>>> import ultraplot as uplt >>> fig, ax = uplt.subplots() >>> ax.format(ticklen=5, metalinewidth=2)
Return a dictionary filled with settings whose names match the string values in the input dictionary. Optionally limit the search to the context level.
Return a single setting. Optionally limit the search to the context level.
Load settings from the specified file.
path (path-like) – The file path.
Return locations of files named ultraplotrc
in this directory and in parent directories. “Hidden” files with a leading dot are also recognized. These are automatically loaded when ultraplot is imported.
Return locations of folders named ultraplot_cmaps
, ultraplot_cycles
, ultraplot_colors
, and ultraplot_fonts
in this directory and in parent directories. “Hidden” folders with a leading dot are also recognized. Files in these directories are automatically loaded when ultraplot is imported.
Reset the configurator to its initial state.
Save the current settings to a ultraplotrc
file. This writes the default values commented out plus the values that differ from the defaults at the top of the file.
path (path-like, default: 'ultraplotrc'
) – The file name and/or directory. The default file name is ultraplotrc
and the default directory is the current directory.
user (bool
, default: True
) – If True
then settings that have been changed
from the ultraplot defaults are shown uncommented at the top of the file.
backup (bool
, default: True
) – Whether to “backup” an existing file by renaming with the suffix .bak
or overwrite an existing file.
comment (bool
, optional) – Whether to comment out the default settings. If not passed this takes the same value as user
.
description (bool
, default: False
) – Whether to include descriptions of each setting (as seen in the user guide table) as comments.
Update several settings at once.
*args (str
or dict-like, optional) – A dictionary containing rc
keys and values. You can also pass a “category” name as the first argument, in which case all settings are prepended with 'category.'
. For example, rc.update('axes', labelsize=20, titlesize=20)
changes the rc['axes.labelsize']
and rc['axes.titlesize']
settings.
**kwargs – rc
keys and values passed as keyword arguments. If the name has dots, simply omit them.
Return location of the default ultraplotrc file. On Linux, this is either $XDG_CONFIG_HOME/ultraplot/ultraplotrc
or ~/.config/ultraplot/ultraplotrc
if the XDG directory is unset. On other operating systems, this is ~/.ultraplot/ultraplotrc
. The location ~/.ultraplotrc
or ~/.ultraplot/ultraplotrc
is always returned if the file exists, regardless of the operating system. If multiple valid locations are found, a warning is raised.
Return location of the default ultraplot folder. On Linux, this is either $XDG_CONFIG_HOME/ultraplot
or ~/.config/ultraplot
if the XDG directory is unset. On other operating systems, this is ~/.ultraplot
. The location ~/.ultraplot
is always returned if the folder exists, regardless of the operating system. If multiple valid locations are found, a warning is raised.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4