Skip to content
Merged
Show file tree
Hide file tree
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
Prefer closing brackets on new lines
  • Loading branch information
lukelbd committed Jan 7, 2020
commit c57c7b0c076818d30af16dfaef0bd074bdb62d1b
239 changes: 138 additions & 101 deletions proplot/axes.py

Large diffs are not rendered by default.

41 changes: 25 additions & 16 deletions proplot/axistools.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ def Locator(locator, *args, **kwargs):
if locator not in locators:
raise ValueError(
f'Unknown locator {locator!r}. Options are '
+ ', '.join(map(repr, locators.keys())) + '.')
+ ', '.join(map(repr, locators.keys())) + '.'
)
locator = locators[locator](*args, **kwargs)
elif isinstance(locator, Number): # scalar variable
locator = mticker.MultipleLocator(locator, *args, **kwargs)
Expand Down Expand Up @@ -266,7 +267,8 @@ def Formatter(formatter, *args, date=False, index=False, **kwargs):
if formatter not in formatters:
raise ValueError(
f'Unknown formatter {formatter!r}. Options are '
+ ', '.join(map(repr, formatters.keys())) + '.')
+ ', '.join(map(repr, formatters.keys())) + '.'
)
formatter = formatters[formatter](*args, **kwargs)
elif callable(formatter):
formatter = mticker.FuncFormatter(formatter, *args, **kwargs)
Expand Down Expand Up @@ -348,7 +350,8 @@ def Scale(scale, *args, **kwargs):
if args or kwargs:
_warn_proplot(
f'Scale {scale!r} is a scale *preset*. Ignoring positional '
'argument(s): {args} and keyword argument(s): {kwargs}. ')
'argument(s): {args} and keyword argument(s): {kwargs}. '
)
scale, *args = SCALE_PRESETS[scale]
# Get scale
scale = scale.lower()
Expand All @@ -357,7 +360,8 @@ def Scale(scale, *args, **kwargs):
else:
raise ValueError(
f'Unknown scale or preset {scale!r}. Options are '
+ ', '.join(map(repr, list(scales) + list(SCALE_PRESETS))) + '.')
+ ', '.join(map(repr, list(scales) + list(SCALE_PRESETS))) + '.'
)
return scale(*args, **kwargs)


Expand All @@ -382,9 +386,11 @@ class AutoFormatter(mticker.ScalarFormatter):
3. Allows user to add arbitrary prefix or suffix to every
tick label string.
"""
def __init__(self, *args,
zerotrim=None, precision=None, tickrange=None,
prefix=None, suffix=None, negpos=None, **kwargs):
def __init__(
self, *args,
zerotrim=None, precision=None, tickrange=None,
prefix=None, suffix=None, negpos=None, **kwargs
):
"""
Parameters
----------
Expand Down Expand Up @@ -543,7 +549,8 @@ def _scale_factory(scale, axis, *args, **kwargs):
if scale not in scales:
raise ValueError(
f'Unknown scale {scale!r}. Options are '
+ ', '.join(map(repr, scales.keys())) + '.')
+ ', '.join(map(repr, scales.keys())) + '.'
)
return scales[scale](*args, **kwargs)


Expand Down Expand Up @@ -761,11 +768,12 @@ class FuncScale(_ScaleBase, mscale.ScaleBase):
name = 'function'
"""The registered scale name."""

def __init__(self, arg, invert=False, parent_scale=None,
major_locator=None, minor_locator=None,
major_formatter=None, minor_formatter=None,
smart_bounds=None,
):
def __init__(
self, arg, invert=False, parent_scale=None,
major_locator=None, minor_locator=None,
major_formatter=None, minor_formatter=None,
smart_bounds=None,
):
"""
Parameters
----------
Expand Down Expand Up @@ -1014,8 +1022,8 @@ class ExpScale(_ScaleBase, mscale.ScaleBase):
"""The registered scale name."""

def __init__(
self, a=np.e, b=1, c=1, inverse=False, minpos=1e-300,
**kwargs):
self, a=np.e, b=1, c=1, inverse=False, minpos=1e-300, **kwargs
):
"""
Parameters
----------
Expand Down Expand Up @@ -1320,7 +1328,8 @@ def __init__(self, threshs, scales, zero_dists=None):
any((dists == 0) != (scales == 0)) or zero_dists is None):
raise ValueError(
'Got zero scales and distances in different places or '
'zero_dists is None.')
'zero_dists is None.'
)
self._scales = scales
self._threshs = threshs
with np.errstate(divide='ignore', invalid='ignore'):
Expand Down
33 changes: 22 additions & 11 deletions proplot/projs.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,13 @@ def Proj(name, basemap=False, **kwargs):
if 'boundinglat' in kwargs:
raise ValueError(
f'"boundinglat" must be passed to the ax.format() command '
'for cartopy axes.')
'for cartopy axes.'
)
if crs is None:
raise ValueError(
f'Unknown projection {name!r}. Options are: '
+ ', '.join(map(repr, cartopy_names.keys())))
+ ', '.join(map(repr, cartopy_names.keys()))
)
proj = crs(**kwargs)
aspect = (np.diff(proj.x_limits) / np.diff(proj.y_limits))[0]
return proj, aspect
Expand All @@ -197,8 +199,10 @@ def __init__(self, central_longitude=0, globe=None,
a = globe.semimajor_axis or WGS84_SEMIMAJOR_AXIS
b = globe.semiminor_axis or a
if b != a or globe.ellipse is not None:
_warn_proplot(f'The {self.name!r} projection does not handle '
'elliptical globes.')
_warn_proplot(
f'The {self.name!r} projection does not handle '
'elliptical globes.'
)

proj4_params = {'proj': 'hammer', 'lon_0': central_longitude}
super().__init__(proj4_params, central_longitude,
Expand Down Expand Up @@ -230,8 +234,10 @@ def __init__(self, central_longitude=0, globe=None,
a = globe.semimajor_axis or WGS84_SEMIMAJOR_AXIS
b = globe.semiminor_axis or a
if b != a or globe.ellipse is not None:
_warn_proplot(f'The {self.name!r} projection does not handle '
'elliptical globes.')
_warn_proplot(
f'The {self.name!r} projection does not handle '
'elliptical globes.'
)

proj4_params = {'proj': 'aitoff', 'lon_0': central_longitude}
super().__init__(proj4_params, central_longitude,
Expand Down Expand Up @@ -263,8 +269,10 @@ def __init__(self, central_longitude=0, globe=None,
a = globe.semimajor_axis or WGS84_SEMIMAJOR_AXIS
b = globe.semiminor_axis or a
if b != a or globe.ellipse is not None:
_warn_proplot(f'The {self.name!r} projection does not handle '
'elliptical globes.')
_warn_proplot(
f'The {self.name!r} projection does not handle '
'elliptical globes.'
)

proj4_params = {'proj': 'kav7', 'lon_0': central_longitude}
super().__init__(proj4_params, central_longitude,
Expand Down Expand Up @@ -296,8 +304,10 @@ def __init__(self, central_longitude=0, globe=None,
a = globe.semimajor_axis or WGS84_SEMIMAJOR_AXIS
b = globe.semiminor_axis or a
if b != a or globe.ellipse is not None:
_warn_proplot(f'The {self.name!r} projection does not handle '
'elliptical globes.')
_warn_proplot(
f'The {self.name!r} projection does not handle '
'elliptical globes.'
)

proj4_params = {'proj': 'wintri', 'lon_0': central_longitude}
super().__init__(proj4_params, central_longitude,
Expand Down Expand Up @@ -473,4 +483,5 @@ def __init__(self, central_longitude=0.0, globe=None):
if _unavail:
_warn_proplot(
f'Cartopy projection(s) {", ".join(map(repr, _unavail))} are '
f'unavailable. Consider updating to cartopy >= 0.17.0.')
f'unavailable. Consider updating to cartopy >= 0.17.0.'
)
22 changes: 9 additions & 13 deletions proplot/rctools.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,14 +448,9 @@ def _tabulate(rcdict):
'rivers.linewidth',
'subplots.axpad',
'subplots.axwidth',
'subplots.innerspace',
'subplots.pad',
'subplots.panelpad',
'subplots.panelspace',
'subplots.panelwidth',
'subplots.titlespace',
'subplots.xlabspace',
'subplots.ylabspace',
'suptitle.color',
'suptitle.size',
'suptitle.weight',
Expand Down Expand Up @@ -551,7 +546,8 @@ def _get_synced_params(key, value):
mcolors.ListedColormap))
raise ValueError(
f'Invalid cycle name {cycle!r}. Options are: '
', '.join(map(repr, cycles)) + '.')
', '.join(map(repr, cycles)) + '.'
)
if rgbcycle and cycle.lower() == 'colorblind':
regcolors = colors + [(0.1, 0.1, 0.1)]
elif mcolors.to_rgb('r') != (1.0, 0.0, 0.0): # reset
Expand Down Expand Up @@ -751,7 +747,8 @@ def __enter__(self):
"""Apply settings from the most recent context block."""
if not self._context:
raise RuntimeError(
f'rc context must be initialized with rc.context().')
f'rc object must be initialized with rc.context().'
)
*_, kwargs, cache, restore = self._context[-1]

def _update(rcdict, newdict):
Expand All @@ -768,7 +765,8 @@ def __exit__(self, *args):
"""Restore settings from the most recent context block."""
if not self._context:
raise RuntimeError(
f'rc context must be initialized with rc.context().')
f'rc object must be initialized with rc.context().'
)
*_, restore = self._context[-1]
for key, value in restore.items():
rc_short, rc_long, rc = _get_synced_params(key, value)
Expand Down Expand Up @@ -990,10 +988,7 @@ def fill(self, props, *, context=False):
Parameters
----------
props : dict-like
Dictionary whose values are names of settings. The values
are replaced with the corresponding property only if
`~rc_configurator.__getitem__` does not return ``None``. Otherwise,
that key, value pair is omitted from the output dictionary.
Dictionary whose values are `rc` setting names.
context : bool, optional
If ``True``, then each setting that is not found in the
context mode dictionaries is omitted from the output dictionary.
Expand Down Expand Up @@ -1152,7 +1147,8 @@ def ipython_matplotlib(backend=None, fmt=None):
else:
raise ValueError(
f'Invalid inline backend format {fmt!r}. '
'Must be string or list thereof.')
'Must be string or list thereof.'
)
ipython.magic(f'config InlineBackend.figure_formats = {fmt!r}')
ipython.magic('config InlineBackend.rc = {}') # no notebook overrides
ipython.magic('config InlineBackend.close_figures = True') # memory issues
Expand Down
Loading