Skip to content

Norm should be passed to facetgrid too #1160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ Bug fixes
- Fixed sub-optimal performance in certain operations with object arrays (:issue:`1121`).
By `Yves Delley <https://github.com/burnpanck>`_.

- Fixed a bug whith facetgrid (the ``norm`` keyword was ignored, :issue:`1159`).
By `Fabien Maussion <https://github.com/fmaussion>`_.

.. _whats-new.0.8.2:

v0.8.2 (18 August 2016)
Expand Down
6 changes: 3 additions & 3 deletions xarray/plot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def _color_palette(cmap, n_colors):

def _determine_cmap_params(plot_data, vmin=None, vmax=None, cmap=None,
center=None, robust=False, extend=None,
levels=None, filled=True, cnorm=None):
levels=None, filled=True, norm=None):
"""
Use some heuristics to set good defaults for colorbar and range.

Expand Down Expand Up @@ -196,10 +196,10 @@ def _determine_cmap_params(plot_data, vmin=None, vmax=None, cmap=None,
extend = _determine_extend(calc_data, vmin, vmax)

if levels is not None:
cmap, cnorm = _build_discrete_cmap(cmap, levels, extend, filled)
cmap, norm = _build_discrete_cmap(cmap, levels, extend, filled)

return dict(vmin=vmin, vmax=vmax, cmap=cmap, extend=extend,
levels=levels, norm=cnorm)
levels=levels, norm=norm)


def _infer_xy_labels(darray, x, y):
Expand Down
12 changes: 10 additions & 2 deletions xarray/test/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ class TestPlot1D(PlotTestCase):

def setUp(self):
d = [0, 1.1, 0, 2]
self.darray = DataArray(d, coords={'period': range(len(d))})
self.darray = DataArray(d, coords={'period': range(len(d))},
dims='period')

def test_xlabel_is_index_name(self):
self.darray.plot()
Expand All @@ -206,7 +207,8 @@ def test_can_pass_in_axis(self):
self.pass_in_axis(self.darray.plot.line)

def test_nonnumeric_index_raises_typeerror(self):
a = DataArray([1, 2, 3], {'letter': ['a', 'b', 'c']})
a = DataArray([1, 2, 3], {'letter': ['a', 'b', 'c']},
dims='letter')
with self.assertRaisesRegexp(TypeError, r'[Pp]lot'):
a.plot.line()

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

def test_can_set_norm(self):
norm = mpl.colors.SymLogNorm(0.1)
self.g.map_dataarray(xplt.imshow, 'x', 'y', norm=norm)
for image in plt.gcf().findobj(mpl.image.AxesImage):
self.assertIs(image.norm, norm)

def test_figure_size(self):

self.assertArrayEqual(self.g.fig.get_size_inches(), (10, 3))
Expand Down