Skip to content

Commit 91d46cf

Browse files
committed
Merge branch 'master' into allow-add-subplot
2 parents 7c9419d + e74acc3 commit 91d46cf

File tree

6 files changed

+49
-45
lines changed

6 files changed

+49
-45
lines changed

docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# WARNING: Pip install hangs onto older commits unless __version__ is changed
33
# since otherwise setup.py will not think it is necessary to rebuild
44
lxml>=4.0.0
5+
pyyaml>=5.0.0
56
numpy>=1.14
67
ipython>=7.0.0
78
matplotlib>=3.0

proplot/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ def _warning_proplot(message, category, filename, lineno, line=None):
3535
# WARNING: Import order is meaningful! Loads modules that are dependencies
3636
# of other modules last, and loads styletools early so we can try to update
3737
# TTFPATH before the fontManager is loaded by other matplotlib modules
38-
from .utils import * # misc stuff, debug mode
38+
from .utils import DEBUG
39+
from .utils import *
3940
if DEBUG:
4041
import time
4142
t = time.clock()

proplot/axes.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2957,13 +2957,14 @@ def _format_apply(self, patch_kw, lonlim, latlim, boundinglat,
29572957
latlines[-1] -= eps
29582958
gl.ylocator = mticker.FixedLocator(latlines)
29592959
# Grid label toggling
2960-
if not isinstance(self.projection, (ccrs.Mercator, ccrs.PlateCarree)):
2961-
if latarray is not None and any(latarray):
2962-
warnings.warn(f'Cannot add gridline labels on cartopy {self.projection} projection.')
2963-
latarray = [0]*4
2964-
if lonarray is not None and any(lonarray):
2965-
warnings.warn(f'Cannot add gridline labels on cartopy {self.projection} projection.')
2966-
lonarray = [0]*4
2960+
# Let cartopy issue warning when no labels possible
2961+
# if not isinstance(self.projection, (ccrs.Mercator, ccrs.PlateCarree)):
2962+
# if latarray is not None and any(latarray):
2963+
# warnings.warn(f'Cannot add gridline labels on cartopy {self.projection} projection.')
2964+
# latarray = [0]*4
2965+
# if lonarray is not None and any(lonarray):
2966+
# warnings.warn(f'Cannot add gridline labels on cartopy {self.projection} projection.')
2967+
# lonarray = [0]*4
29672968
if latarray is not None:
29682969
gl.ylabels_left = latarray[0]
29692970
gl.ylabels_right = latarray[1]

proplot/axistools.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,8 @@ def __init__(self, axis, **kwargs):
802802
def get_transform(self):
803803
return self._transform
804804
def set_default_locators_and_formatters(self, axis):
805-
axis.set_smart_bounds(True) # may prevent ticks from extending off sides
805+
# TODO: add example to bug list, smart bounds screws up ticking!
806+
# axis.set_smart_bounds(True) # may prevent ticks from extending off sides
806807
axis.set_major_formatter(Formatter('default'))
807808
axis.set_minor_formatter(Formatter('null'))
808809

proplot/subplots.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ def _panels_kwargs(side,
567567
default = rc['subplots.panelwidth']
568568
share = _notNone(share, (not filled))
569569
width = units(_notNone(width, default))
570-
space = _notNone(space, units(rc['subplots.' + ('panel' if share
570+
space = _notNone(units(space), units(rc['subplots.' + ('panel' if share
571571
and not figure
572572
else 'xlab' if s == 'b' else 'ylab' if s == 'l'
573573
else 'inner' if figure else 'panel') + 'space']))
@@ -1827,14 +1827,6 @@ def subplots(array=None, ncols=1, nrows=1,
18271827
18281828
Parameters
18291829
----------
1830-
ncols, nrows : int, optional
1831-
Number of columns, rows. Ignored if `array` is not ``None``.
1832-
Use these arguments for simpler subplot grids.
1833-
order : {'C', 'F'}, optional
1834-
Whether subplots are numbered in column-major (``'C'``) or row-major
1835-
(``'F'``) order. Analogous to `numpy.array` ordering. This controls
1836-
the order axes appear in the `axs` list, and the order of subplot
1837-
a-b-c labeling (see `~proplot.axes.Axes.format`).
18381830
array : array-like of int, optional
18391831
2-dimensional array specifying complex grid of subplots. Think of
18401832
this array as a "picture" of your figure. For example, the array
@@ -1845,6 +1837,14 @@ def subplots(array=None, ncols=1, nrows=1,
18451837
``0`` indicates an empty space. For example, ``[[1, 1, 1], [2, 0, 3]]``
18461838
creates one long subplot in the top row with two subplots in the bottom
18471839
row separated by a space.
1840+
ncols, nrows : int, optional
1841+
Number of columns, rows. Ignored if `array` is not ``None``.
1842+
Use these arguments for simpler subplot grids.
1843+
order : {'C', 'F'}, optional
1844+
Whether subplots are numbered in column-major (``'C'``) or row-major
1845+
(``'F'``) order. Analogous to `numpy.array` ordering. This controls
1846+
the order axes appear in the `axs` list, and the order of subplot
1847+
a-b-c labeling (see `~proplot.axes.Axes.format`).
18481848
figsize : length-2 tuple, optional
18491849
Tuple specifying the figure `(width, height)`.
18501850
width, height : float or str, optional

proplot/utils.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,6 @@
1616
ic = lambda *a: None if not a else (a[0] if len(a) == 1 else a) # noqa
1717
__all__ = ['arange', 'edges', 'units', 'DEBUG']
1818

19-
# Important private helper func
20-
def _notNone(*args, names=None):
21-
"""Returns the first non-``None`` value, used with keyword arg aliases and
22-
for setting default values. Ugly name but clear purpose. Pass the `names`
23-
keyword arg to issue warning if multiple args were passed. Must be list
24-
of non-empty strings."""
25-
if names is None:
26-
for arg in args:
27-
if arg is not None:
28-
return arg
29-
return arg # last one
30-
else:
31-
ret = {}
32-
first = None
33-
if len(names) != len(args) - 1:
34-
raise ValueError(f'Need {len(args)+1} names for {len(args)} args, but got {len(names)} names.')
35-
names = [*names, '']
36-
for name,arg in zip(names,args):
37-
if arg is not None:
38-
if first is None:
39-
first = arg
40-
if name:
41-
ret[name] = arg
42-
if len(ret)>1:
43-
warnings.warn(f'Got conflicting or duplicate keyword args, using the first one: {ret}')
44-
return first
45-
4619
# Debug decorators
4720
DEBUG = False # debug mode, used for profiling and activating timer decorators
4821
def _logger(func):
@@ -86,6 +59,33 @@ def decorator(*args, **kwargs):
8659
decorator.count = 0 # initialize
8760
return decorator
8861

62+
# Important private helper func
63+
def _notNone(*args, names=None):
64+
"""Returns the first non-``None`` value, used with keyword arg aliases and
65+
for setting default values. Ugly name but clear purpose. Pass the `names`
66+
keyword arg to issue warning if multiple args were passed. Must be list
67+
of non-empty strings."""
68+
if names is None:
69+
for arg in args:
70+
if arg is not None:
71+
return arg
72+
return arg # last one
73+
else:
74+
first = None
75+
kwargs = {}
76+
if len(names) != len(args) - 1:
77+
raise ValueError(f'Need {len(args)+1} names for {len(args)} args, but got {len(names)} names.')
78+
names = [*names, '']
79+
for name,arg in zip(names,args):
80+
if arg is not None:
81+
if first is None:
82+
first = arg
83+
if name:
84+
kwargs[name] = arg
85+
if len(kwargs)>1:
86+
warnings.warn(f'Got conflicting or duplicate keyword args, using the first one: {kwargs}')
87+
return first
88+
8989
# Accessible for user
9090
def arange(min_, *args):
9191
"""Identical to `numpy.arange`, but with inclusive endpoints. For

0 commit comments

Comments
 (0)