Skip to content

Commit

Permalink
Fixed inverted QuadMesh bug (#2771)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored and jlstevens committed Jun 5, 2018
1 parent 2e7ac9a commit 2782932
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions holoviews/plotting/bokeh/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,9 @@ def get_data(self, element, ranges, style):
data[x] = np.array(xc)
data[y] = np.array(yc)
else:
xc, yc = (element.interface.coords(element, x, edges=True),
element.interface.coords(element, y, edges=True))
xc, yc = (element.interface.coords(element, x, edges=True, ordered=True),
element.interface.coords(element, y, edges=True, ordered=True))

x0, y0 = cartesian_product([xc[:-1], yc[:-1]], copy=True)
x1, y1 = cartesian_product([xc[1:], yc[1:]], copy=True)
zvals = zdata.flatten() if self.invert_axes else zdata.T.flatten()
Expand Down
12 changes: 12 additions & 0 deletions tests/plotting/bokeh/testquadmeshplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,15 @@ def test_quadmesh_colorbar(self):
plot = bokeh_renderer.get_plot(qmesh)
self.assertIsInstance(plot.handles['colorbar'], ColorBar)
self.assertIs(plot.handles['colorbar'].color_mapper, plot.handles['color_mapper'])

def test_quadmesh_inverted_coords(self):
xs = [0, 1, 2]
ys = [2, 1, 0]
qmesh = QuadMesh((xs, ys, np.random.rand(3, 3)))
plot = bokeh_renderer.get_plot(qmesh)
source = plot.handles['source']
self.assertEqual(source.data['z'], qmesh.dimension_values(2, flat=False).T.flatten())
self.assertEqual(source.data['left'], np.array([-0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 1.5, 1.5, 1.5]))
self.assertEqual(source.data['right'], np.array([0.5, 0.5, 0.5, 1.5, 1.5, 1.5, 2.5, 2.5, 2.5]))
self.assertEqual(source.data['top'], np.array([0.5, 1.5, 2.5, 0.5, 1.5, 2.5, 0.5, 1.5, 2.5]))
self.assertEqual(source.data['bottom'], np.array([-0.5, 0.5, 1.5, -0.5, 0.5, 1.5, -0.5, 0.5, 1.5]))

0 comments on commit 2782932

Please sign in to comment.