Skip to content

Commit 2c7730d

Browse files
authored
Norm should be passed to facetgrid too (#1160)
1 parent 8b54f93 commit 2c7730d

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

doc/whats-new.rst

+3
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ Bug fixes
158158
- Fixed sub-optimal performance in certain operations with object arrays (:issue:`1121`).
159159
By `Yves Delley <https://github.com/burnpanck>`_.
160160

161+
- Fixed a bug whith facetgrid (the ``norm`` keyword was ignored, :issue:`1159`).
162+
By `Fabien Maussion <https://github.com/fmaussion>`_.
163+
161164
.. _whats-new.0.8.2:
162165

163166
v0.8.2 (18 August 2016)

xarray/plot/utils.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def _color_palette(cmap, n_colors):
104104

105105
def _determine_cmap_params(plot_data, vmin=None, vmax=None, cmap=None,
106106
center=None, robust=False, extend=None,
107-
levels=None, filled=True, cnorm=None):
107+
levels=None, filled=True, norm=None):
108108
"""
109109
Use some heuristics to set good defaults for colorbar and range.
110110
@@ -196,10 +196,10 @@ def _determine_cmap_params(plot_data, vmin=None, vmax=None, cmap=None,
196196
extend = _determine_extend(calc_data, vmin, vmax)
197197

198198
if levels is not None:
199-
cmap, cnorm = _build_discrete_cmap(cmap, levels, extend, filled)
199+
cmap, norm = _build_discrete_cmap(cmap, levels, extend, filled)
200200

201201
return dict(vmin=vmin, vmax=vmax, cmap=cmap, extend=extend,
202-
levels=levels, norm=cnorm)
202+
levels=levels, norm=norm)
203203

204204

205205
def _infer_xy_labels(darray, x, y):

xarray/test/test_plot.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ class TestPlot1D(PlotTestCase):
179179

180180
def setUp(self):
181181
d = [0, 1.1, 0, 2]
182-
self.darray = DataArray(d, coords={'period': range(len(d))})
182+
self.darray = DataArray(d, coords={'period': range(len(d))},
183+
dims='period')
183184

184185
def test_xlabel_is_index_name(self):
185186
self.darray.plot()
@@ -206,7 +207,8 @@ def test_can_pass_in_axis(self):
206207
self.pass_in_axis(self.darray.plot.line)
207208

208209
def test_nonnumeric_index_raises_typeerror(self):
209-
a = DataArray([1, 2, 3], {'letter': ['a', 'b', 'c']})
210+
a = DataArray([1, 2, 3], {'letter': ['a', 'b', 'c']},
211+
dims='letter')
210212
with self.assertRaisesRegexp(TypeError, r'[Pp]lot'):
211213
a.plot.line()
212214

@@ -1032,6 +1034,12 @@ def test_can_set_vmin_vmax(self):
10321034
clim = np.array(image.get_clim())
10331035
self.assertTrue(np.allclose(expected, clim))
10341036

1037+
def test_can_set_norm(self):
1038+
norm = mpl.colors.SymLogNorm(0.1)
1039+
self.g.map_dataarray(xplt.imshow, 'x', 'y', norm=norm)
1040+
for image in plt.gcf().findobj(mpl.image.AxesImage):
1041+
self.assertIs(image.norm, norm)
1042+
10351043
def test_figure_size(self):
10361044

10371045
self.assertArrayEqual(self.g.fig.get_size_inches(), (10, 3))

0 commit comments

Comments
 (0)