From 34b810244b18c6173b32ac7422d66a9ef3f39513 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Thu, 12 Sep 2019 16:17:02 +0200 Subject: [PATCH] Allow plotting partially irregular QuadMesh --- holoviews/core/util.py | 25 +++++++++++++++++++++---- holoviews/plotting/bokeh/raster.py | 3 ++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/holoviews/core/util.py b/holoviews/core/util.py index 27a04b6c90..d23c7f82e3 100644 --- a/holoviews/core/util.py +++ b/holoviews/core/util.py @@ -1819,10 +1819,27 @@ def expand_grid_coords(dataset, dim): dataset into an ND-array matching the dimensionality of the dataset. """ - arrays = [dataset.interface.coords(dataset, d.name, True) - for d in dataset.kdims] - idx = dataset.get_dimension_index(dim) - return cartesian_product(arrays, flat=False)[idx].T + irregular = [d.name for d in dataset.kdims + if d is not dim and dataset.interface.irregular(dataset, d)] + if irregular: + array = dataset.interface.coords(dataset, dim, True) + example = dataset.interface.values(dataset, irregular[0], True, False) + if dataset.interface.datatype == 'xarray': + index = dataset.data[irregular[0]].dims.index(dim) + else: + index = (example.ndim - dataset.get_dimension_index(dim) - 1) + shape = list(example.shape) + n = shape.pop(index) + coords = np.broadcast_to(array, tuple(shape)+(n,)) + inds = list(range(dataset.ndims)) + inds[index] = dataset.ndims-1 + inds[-1] = index + return coords.transpose(tuple(inds)) + else: + arrays = [dataset.interface.coords(dataset, d.name, True) + for d in dataset.kdims] + idx = dataset.get_dimension_index(dim) + return cartesian_product(arrays, flat=False)[idx].T def dt64_to_dt(dt64): diff --git a/holoviews/plotting/bokeh/raster.py b/holoviews/plotting/bokeh/raster.py index e339d916e5..e71b60f36e 100644 --- a/holoviews/plotting/bokeh/raster.py +++ b/holoviews/plotting/bokeh/raster.py @@ -207,7 +207,8 @@ def get_data(self, element, ranges, style): cmapper = self._get_colormapper(z, element, ranges, style) cmapper = {'field': z.name, 'transform': cmapper} - irregular = element.interface.irregular(element, x) + irregular = (element.interface.irregular(element, x) or + element.interface.irregular(element, y)) if irregular: mapping = dict(xs='xs', ys='ys', fill_color=cmapper) else: