Created
June 2, 2018 13:29
-
-
Save dcherian/f73e2e50ddccb00d03ae294852283ea9 to your computer and use it in GitHub Desktop.
patch file for yohai
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 3e0429cb3b43db8e74ece681e6b1d2f5f2b638d9 Mon Sep 17 00:00:00 2001 | |
From: dcherian <dcherian@mit.edu> | |
Date: Sat, 2 Jun 2018 07:14:51 -0600 | |
Subject: [PATCH] Fix merge. All tests pass now. | |
--- | |
xarray/plot/facetgrid.py | 2 +- | |
xarray/plot/plot.py | 38 ++++++++++++++++++++++---------------- | |
2 files changed, 23 insertions(+), 17 deletions(-) | |
diff --git a/xarray/plot/facetgrid.py b/xarray/plot/facetgrid.py | |
index bbcbe7f7..771f0879 100644 | |
--- a/xarray/plot/facetgrid.py | |
+++ b/xarray/plot/facetgrid.py | |
@@ -293,7 +293,7 @@ class FacetGrid(object): | |
ax=ax, _labels=False, | |
**kwargs) | |
self._mappables.append(mappable) | |
- _, _, xlabel, ylabel, huelabel = _infer_line_data( | |
+ _, _, _, xlabel, ylabel, huelabel = _infer_line_data( | |
darray=self.data.loc[self.name_dicts.flat[0]], | |
x=x, y=y, hue=hue) | |
diff --git a/xarray/plot/plot.py b/xarray/plot/plot.py | |
index 0d7352b8..6322fc09 100644 | |
--- a/xarray/plot/plot.py | |
+++ b/xarray/plot/plot.py | |
@@ -202,37 +202,42 @@ def _infer_line_data(darray, x, y, hue): | |
if ndims == 1: | |
dim, = darray.dims # get the only dimension name | |
- huelabel = None | |
+ huename = None | |
+ hueplt = None | |
+ huelabel = '' | |
if (x is None and y is None) or x == dim: | |
xplt = darray.coords[dim] | |
yplt = darray | |
- xlabel = dim | |
- ylabel = darray.name | |
else: | |
yplt = darray.coords[dim] | |
xplt = darray | |
- xlabel = darray.name | |
- ylabel = dim | |
+ | |
else: | |
if x is None and y is None and hue is None: | |
raise ValueError('For 2D inputs, please' | |
'specify either hue, x or y.') | |
if y is None: | |
- xlabel, huelabel = _infer_xy_labels(darray=darray, x=x, y=hue) | |
- ylabel = darray.name | |
- xplt = darray.coords[xlabel] | |
- yplt = darray.transpose(xlabel, huelabel) | |
+ xname, huename = _infer_xy_labels(darray=darray, x=x, y=hue) | |
+ yname = darray.name | |
+ xplt = darray.coords[xname] | |
+ yplt = darray.transpose(xname, huename) | |
else: | |
- ylabel, huelabel = _infer_xy_labels(darray=darray, x=y, y=hue) | |
- xlabel = darray.name | |
- xplt = darray.transpose(ylabel, huelabel) | |
- yplt = darray.coords[ylabel] | |
+ yname, huename = _infer_xy_labels(darray=darray, x=y, y=hue) | |
+ xname = darray.name | |
+ xplt = darray.transpose(yname, huename) | |
+ yplt = darray.coords[yname] | |
+ | |
+ hueplt = darray.coords[huename] | |
+ huelabel = label_from_attrs(darray[huename]) | |
+ | |
+ xlabel = label_from_attrs(xplt) | |
+ ylabel = label_from_attrs(yplt) | |
- return xplt, yplt, xlabel, ylabel, huelabel | |
+ return xplt, yplt, hueplt, xlabel, ylabel, huelabel | |
# This function signature should not change so that it can use | |
@@ -307,7 +312,8 @@ def line(darray, *args, **kwargs): | |
_labels = kwargs.pop('_labels', True) | |
ax = get_axis(figsize, size, aspect, ax) | |
- xplt, yplt, xlabel, ylabel, huelabel = _infer_line_data(darray, x, y, hue) | |
+ xplt, yplt, hueplt, xlabel, ylabel, huelabel = \ | |
+ _infer_line_data(darray, x, y, hue) | |
_ensure_plottable(xplt) | |
@@ -324,7 +330,7 @@ def line(darray, *args, **kwargs): | |
if darray.ndim == 2 and add_legend: | |
ax.legend(handles=primitive, | |
- labels=list(huecoords.values), | |
+ labels=list(hueplt.values), | |
title=huelabel) | |
# Rotate dates on xlabels | |
-- | |
2.17.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment