Skip to content

Commit

Permalink
Allow plotting partially irregular QuadMesh
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Sep 12, 2019
1 parent a1e0c03 commit 34b8102
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
25 changes: 21 additions & 4 deletions holoviews/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion holoviews/plotting/bokeh/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 34b8102

Please sign in to comment.