Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b9667cf
Initial commit
lukelbd Dec 19, 2019
83ef32c
Merge branch 'master' into rc-cleanup-fixes
lukelbd Jan 6, 2020
e464a99
Move default props from .proplotrc --> rctools.py
lukelbd Jan 6, 2020
e760807
Improve rc_configurator getitem/setitem, add helper func
lukelbd Jan 6, 2020
d6b6020
Update get(), fill(), category(); add dict() and iterator methods
lukelbd Jan 6, 2020
a82dd68
Fix rc_configurator.context() bug
lukelbd Jan 6, 2020
dea6d94
Improve iter, contains, and string repr methods
lukelbd Jan 6, 2020
44a4bc9
Improve _loc_translate + _get_title_props, related cleanup
lukelbd Jan 7, 2020
424bc67
Remove Axes.context, update rc lookups, related cleanup
lukelbd Jan 7, 2020
8e7655e
Add x/ylinewidth, x/ygridcolor XYAxes.format kwargs
lukelbd Jan 7, 2020
25f7bd8
Fix rc lookups in other files
lukelbd Jan 7, 2020
77e406a
Remove Axes.context, add documented Axes.number prop
lukelbd Jan 7, 2020
61a45d4
Update changelog and index
lukelbd Jan 7, 2020
93c8aa5
Cleaner install instructions
lukelbd Jan 7, 2020
da123eb
Remove rc._init reference
lukelbd Jan 7, 2020
5b45522
Fix bug/conflict between ipython_* funcs and rc.__init__
lukelbd Jan 7, 2020
1bf78ce
Remove _getitem_mode assignment
lukelbd Jan 7, 2020
3c44865
Add _get_space function, simplify _panel_kwargs function
lukelbd Jan 7, 2020
3fb9a52
Rename _panel_kwargs --> _get_panelargs
lukelbd Jan 7, 2020
dba9f70
Use _get_space; remove refs to subplots.ylabspace, etc.
lukelbd Jan 7, 2020
fdfe042
Update default font sizes
lukelbd Jan 7, 2020
3218c2a
Change refs from panelspace --> panelpad
lukelbd Jan 7, 2020
1ab92ca
Remove subplots.ylabspace, etc. from configuration docs
lukelbd Jan 7, 2020
16ae44f
Fix _loc_translate bug
lukelbd Jan 7, 2020
6629efb
Remove panel_kw from colorbar/legend_wrapper
lukelbd Jan 7, 2020
ef33694
Update changelog
lukelbd Jan 7, 2020
20b9f5b
No longer change figure.dpi
lukelbd Jan 7, 2020
db78bc0
Fix rc.category bug, minor subplots bugs
lukelbd Jan 7, 2020
c57c7b0
Prefer closing brackets on new lines
lukelbd Jan 7, 2020
578aa8b
Better install instructions
lukelbd Jan 7, 2020
7acffb6
Update changelog
lukelbd Jan 7, 2020
8da19f5
Remove outdated cache=False ref, remove debug statement
lukelbd Jan 7, 2020
3ca9a02
Minor BasemapAxes bugfix
lukelbd Jan 7, 2020
22af8f9
Notebook examples formatting improvements
lukelbd Jan 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix bug/conflict between ipython_* funcs and rc.__init__
  • Loading branch information
lukelbd committed Jan 7, 2020
commit 5b45522c73792a0ff46691d54b1e37decab04cd1
61 changes: 33 additions & 28 deletions proplot/rctools.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,15 +536,6 @@ def _get_synced_params(key, value):
if '.' in key:
pass

# Special ipython settings
# TODO: Put this inside __setitem__?
elif key == 'matplotlib':
ipython_matplotlib(value)
elif key == 'autosave':
ipython_autosave(value)
elif key == 'autoreload':
ipython_autoreload(value)

# Cycler
elif key in ('cycle', 'rgbcycle'):
if key == 'rgbcycle':
Expand Down Expand Up @@ -749,9 +740,13 @@ def __init__(self, local=True):
raise err
for key, value in (data or {}).items():
try:
self[key] = value
rc_short, rc_long, rc = _get_synced_params(key, value)
except KeyError:
raise RuntimeError(f'{file!r} has invalid key {key!r}.')
else:
rcParamsShort.update(rc_short)
rcParamsLong.update(rc_long)
rcParams.update(rc)

def __enter__(self):
"""Apply settings from the most recent context block."""
Expand All @@ -777,7 +772,10 @@ def __exit__(self, *args):
f'rc context must be initialized with rc.context().')
*_, restore = self._context[-1]
for key, value in restore.items():
self[key] = value
rc_short, rc_long, rc = _get_synced_params(key, value)
rcParamsShort.update(rc_short)
rcParamsLong.update(rc_long)
rcParams.update(rc)
del self._context[-1]

def __delitem__(self, *args):
Expand Down Expand Up @@ -814,8 +812,14 @@ def __setattr__(self, attr, value):

def __setitem__(self, key, value):
"""Modify an `rcParams \
<https://matplotlib.org/users/customizing.html>`__,
<https://matplotlibcorg/users/customizing.html>`__,
:ref:`rcParamsLong`, and :ref:`rcParamsShort` setting(s)."""
if key == 'matplotlib':
return ipython_matplotlib(value)
elif key == 'autosave':
return ipython_autosave(value)
elif key == 'autoreload':
return ipython_autoreload(value)
rc_short, rc_long, rc = _get_synced_params(key, value)
rcParamsShort.update(rc_short)
rcParamsLong.update(rc_long)
Expand Down Expand Up @@ -1016,32 +1020,30 @@ def keys(self):

def update(self, *args, **kwargs):
"""
Update multiple settings at once.
Update several settings at once with a dictionary and/or
keyword arguments.

Parameters
----------
*args : str, dict, or (str, dict)
The first argument can optionally be a "category" string name,
in which case all other setting names passed to this function are
prepended with the string ``cat + '.'``. For example,
*args : str, dict, or (str, dict), 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
:rcraw:`axes.labelsize` and :rcraw:`axes.titlesize` properties.

The first or second argument can also be a dictionary of `rc`
names and values.
**kwargs
`rc` names and values passed as keyword arguments. If the
**kwargs, optional
`rc` keys and values passed as keyword arguments. If the
name has dots, simply omit them.
"""
# Parse args
kw = {}
prefix = ''
if len(args) > 2:
raise ValueError(
'Accepts 1-2 positional arguments. Use plot.rc.update(kw) '
'to update a bunch of names, or plot.rc.update(category, kw) '
'to update subcategories belonging to single category '
'e.g. axes. Keyword args are added to the kw dict.')
f'rc.update() accepts 1-2 arguments, got {len(args)}. Usage '
'is rc.update(kw), rc.update(category, kw), '
'rc.update(**kwargs), or rc.update(category, **kwargs).'
)
elif len(args) == 2:
prefix = args[0]
kw = args[1]
Expand Down Expand Up @@ -1129,7 +1131,8 @@ def ipython_matplotlib(backend=None, fmt=None):
ibackend = 'qt'
try:
ipython.magic('matplotlib ' + ibackend)
rc.reset()
if 'rc' in globals(): # should always be True, but just in case
rc.reset()
except KeyError:
if backend != 'auto':
_warn_proplot(f'{"%matplotlib " + backend!r} failed.')
Expand Down Expand Up @@ -1214,7 +1217,9 @@ def ipython_autosave(autosave=None):
#: See :ref:`Configuring proplot` for details.
rc = rc_configurator()

# Call setup functions
# Manually call setup functions after rc has been instantiated
# We cannot call these inside rc.__init__ because ipython_matplotlib may
# need to reset the configurator to overwrite backend-imposed settings!
ipython_matplotlib()
ipython_autoreload()
ipython_autosave()