From f20d0d12197e20f0baa258347e8efdf9811f9fa1 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sat, 31 Aug 2019 04:24:59 -0400 Subject: [PATCH 6/6] Use drawstyle instead of linestyle in plot.step. Mixing the two is deprecated in Matplotlib 3.1, and breaks the doc build if warnings are set to errors (which they are in new IPython sphinx extensions.) Signed-off-by: Elliott Sales de Andrade --- xarray/plot/plot.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/xarray/plot/plot.py b/xarray/plot/plot.py index 9d0bf671..55fa033b 100644 --- a/xarray/plot/plot.py +++ b/xarray/plot/plot.py @@ -252,16 +252,16 @@ def line(darray, *args, row=None, col=None, figsize=None, aspect=None, # Remove pd.Intervals if contained in xplt.values. if _valid_other_type(xplt.values, [pd.Interval]): # Is it a step plot? (see matplotlib.Axes.step) - if kwargs.get('linestyle', '').startswith('steps-'): + if kwargs.get('drawstyle', '').startswith('steps-'): xplt_val, yplt_val = _interval_to_double_bound_points(xplt.values, yplt.values) # Remove steps-* to be sure that matplotlib is not confused - kwargs['linestyle'] = (kwargs['linestyle'] + kwargs['drawstyle'] = (kwargs['drawstyle'] .replace('steps-pre', '') .replace('steps-post', '') .replace('steps-mid', '')) - if kwargs['linestyle'] == '': - del kwargs['linestyle'] + if kwargs['drawstyle'] == '': + del kwargs['drawstyle'] else: xplt_val = _interval_to_mid_points(xplt.values) yplt_val = yplt.values @@ -303,7 +303,7 @@ def line(darray, *args, row=None, col=None, figsize=None, aspect=None, return primitive -def step(darray, *args, where='pre', linestyle=None, ls=None, **kwargs): +def step(darray, *args, where='pre', drawstyle=None, ds=None, **kwargs): """ Step plot of DataArray index against values @@ -332,16 +332,16 @@ def step(darray, *args, where='pre', linestyle=None, ls=None, **kwargs): raise ValueError("'where' argument to step must be " "'pre', 'post' or 'mid'") - if ls is not None: - if linestyle is None: - linestyle = ls + if ds is not None: + if drawstyle is None: + drawstyle = ds else: - raise TypeError('ls and linestyle are mutually exclusive') - if linestyle is None: - linestyle = '' - linestyle = 'steps-' + where + linestyle + raise TypeError('ds and drawstyle are mutually exclusive') + if drawstyle is None: + drawstyle = '' + drawstyle = 'steps-' + where + drawstyle - return line(darray, *args, linestyle=linestyle, **kwargs) + return line(darray, *args, drawstyle=drawstyle, **kwargs) def hist(darray, figsize=None, size=None, aspect=None, ax=None, -- 2.21.0