Skip to content

Commit db78bc0

Browse files
committed
Fix rc.category bug, minor subplots bugs
1 parent 20b9f5b commit db78bc0

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

proplot/rctools.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -851,15 +851,18 @@ def _get_item(self, key, mode=None):
851851
else:
852852
return None
853853

854-
def category(self, cat, *, context=False):
854+
def category(self, cat, *, trimcat=True, context=False):
855855
"""
856856
Return a dictionary of settings beginning with the substring
857857
``cat + '.'``.
858858
859859
Parameters
860860
----------
861861
cat : str, optional
862-
The `rc` settings category.
862+
The `rc` setting category.
863+
trimcat : bool, optional
864+
Whether to trim ``cat`` from the key names in the output
865+
dictionary. Default is ``True``.
863866
context : bool, optional
864867
If ``True``, then each category setting that is not found in the
865868
context mode dictionaries is omitted from the output dictionary.
@@ -868,16 +871,19 @@ def category(self, cat, *, context=False):
868871
if cat not in RC_CATEGORIES:
869872
raise ValueError(
870873
f'Invalid rc category {cat!r}. Valid categories are '
871-
', '.join(map(repr, RC_CATEGORIES)) + '.')
874+
', '.join(map(repr, RC_CATEGORIES)) + '.'
875+
)
872876
kw = {}
873877
mode = 0 if not context else None
874878
for rcdict in (rcParamsLong, rcParams):
875879
for key in rcdict:
876-
if not re.search(f'^{cat}[.][^.]+$', key):
880+
if not re.match(fr'\A{cat}\.[^.]+\Z', key):
877881
continue
878882
value = self._get_item(key, mode)
879883
if value is None:
880884
continue
885+
if trimcat:
886+
key = re.sub(fr'\A{cat}\.', '', key)
881887
kw[key] = value
882888
return kw
883889

proplot/subplots.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ def _get_panelargs(
551551
width = units(width)
552552
if space is None:
553553
key = ('wspace' if s in 'lr' else 'hspace')
554-
pad = (rc['axpad'] if figure else rc['panelpad'])
554+
pad = (rc['subplots.axpad'] if figure else rc['subplots.panelpad'])
555555
space = _get_space(key, share, pad=pad)
556556
return share, width, space, space_user
557557

@@ -2192,10 +2192,11 @@ def subplots(
21922192
right = _notNone(right, _get_space('right'))
21932193
bottom = _notNone(bottom, _get_space('bottom'))
21942194
top = _notNone(top, _get_space('top'))
2195-
wratios, hratios = [*wratios], [*hratios] # copies
21962195
wspace, hspace = np.array(wspace), np.array(hspace) # also copies!
21972196
wspace[wspace == None] = _get_space('wspace', sharex) # noqa
21982197
hspace[hspace == None] = _get_space('hspace', sharey) # noqa
2198+
wratios, hratios = list(wratios), list(hratios)
2199+
wspace, hspace = list(wspace), list(hspace)
21992200

22002201
# Parse arguments, fix dimensions in light of desired aspect ratio
22012202
figsize, gridspec_kw, subplots_kw = _subplots_geometry(

0 commit comments

Comments
 (0)