Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
yohai committed Jul 11, 2018
1 parent 31019d8 commit 5b3714c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion xarray/plot/facetgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def map_dataarray_line(self, plotfunc, x=None, y=None, hue=None, **kwargs):
"""
from .plot import (_infer_line_data, _infer_scatter_data,
line, dataset_scatter)
line, dataset_scatter)

add_legend = kwargs.pop('add_legend', True)
kwargs['add_legend'] = False
Expand Down
19 changes: 11 additions & 8 deletions xarray/plot/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ def _is_monotonic(coord, axis=0):
return np.all(delta_pos) or np.all(delta_neg)


def _infer_interval_breaks(coord, axis=0):
def _infer_interval_breaks(coord, axis=0, check_monotonic=False):
"""
>>> _infer_interval_breaks(np.arange(5))
array([-0.5, 0.5, 1.5, 2.5, 3.5, 4.5])
Expand All @@ -923,7 +923,7 @@ def _infer_interval_breaks(coord, axis=0):
"""
coord = np.asarray(coord)

if not _is_monotonic(coord, axis=axis):
if check_monotonic and not _is_monotonic(coord, axis=axis):
raise ValueError("The input coordinate is not sorted in increasing "
"order along axis %d. This can lead to unexpected "
"results. Consider calling the `sortby` method on "
Expand Down Expand Up @@ -962,8 +962,8 @@ def pcolormesh(x, y, z, ax, infer_intervals=None, **kwargs):

if infer_intervals:
if len(x.shape) == 1:
x = _infer_interval_breaks(x)
y = _infer_interval_breaks(y)
x = _infer_interval_breaks(x, check_monotonic=True)
y = _infer_interval_breaks(y, check_monotonic=True)
else:
# we have to infer the intervals on both axes
x = _infer_interval_breaks(x, axis=1)
Expand All @@ -985,7 +985,7 @@ def pcolormesh(x, y, z, ax, infer_intervals=None, **kwargs):

def dataset_scatter(ds, x=None, y=None, hue=None, col=None, row=None,
col_wrap=None, sharex=True, sharey=True, aspect=None,
size=None, subplot_kws=None, add_legend=True, **kwargs):
size=None, subplot_kws=None, add_legend=True, **kwargs):
if col or row:
ax = kwargs.pop('ax', None)
figsize = kwargs.pop('figsize', None)
Expand All @@ -996,14 +996,17 @@ def dataset_scatter(ds, x=None, y=None, hue=None, col=None, row=None,
if size is None:
size = 3
elif figsize is not None:
raise ValueError('cannot provide both `figsize` and `size` arguments')
raise ValueError('cannot provide both `figsize` and'
'`size` arguments')

g = FacetGrid(data=ds, col=col, row=row, col_wrap=col_wrap,
sharex=sharex, sharey=sharey, figsize=figsize,
aspect=aspect, size=size, subplot_kws=subplot_kws)
return g.map_dataarray_line(x=x, y=y, hue=hue, plotfunc=dataset_scatter, **kwargs)
return g.map_dataarray_line(x=x, y=y, hue=hue,
plotfunc=dataset_scatter, **kwargs)

xplt, yplt, hueplt, xlabel, ylabel, huelabel = _infer_scatter_data(ds, x, y, hue)
xplt, yplt, hueplt, xlabel, ylabel, huelabel = _infer_scatter_data(ds, x,
y, hue)

figsize = kwargs.pop('figsize', None)
ax = kwargs.pop('ax', None)
Expand Down

0 comments on commit 5b3714c

Please sign in to comment.