Skip to content

Commit fa4696e

Browse files
jhoofwijkbasnijholt
authored andcommitted
fix plotting resolution for larger scaled learnerND
1 parent a0d5e69 commit fa4696e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

adaptive/learner/learnerND.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ def plot(self, n=None, tri_alpha=0):
506506
if self.vdim > 1:
507507
raise NotImplementedError('holoviews currently does not support',
508508
'3D surface plots in bokeh.')
509-
if len(self.ndim) != 2:
509+
if self.ndim != 2:
510510
raise NotImplementedError("Only 2D plots are implemented: You can "
511511
"plot a 2D slice with 'plot_slice'.")
512512
x, y = self._bbox
@@ -516,7 +516,9 @@ def plot(self, n=None, tri_alpha=0):
516516
if n is None:
517517
# Calculate how many grid points are needed.
518518
# factor from A=√3/4 * a² (equilateral triangle)
519-
n = int(0.658 / np.sqrt(np.min(self.tri.volumes())))
519+
scale_factor = np.product(np.diag(self._transform))
520+
a_sq = np.sqrt(np.min(self.tri.volumes()) * scale_factor)
521+
n = max(10, int(0.658 / a_sq))
520522

521523
xs = ys = np.linspace(0, 1, n)
522524
xs = xs * (x[1] - x[0]) + x[0]
@@ -585,7 +587,9 @@ def plot_slice(self, cut_mapping, n=None):
585587
if n is None:
586588
# Calculate how many grid points are needed.
587589
# factor from A=√3/4 * a² (equilateral triangle)
588-
n = int(0.658 / np.sqrt(np.min(self.tri.volumes())))
590+
scale_factor = np.product(np.diag(self._transform))
591+
a_sq = np.sqrt(np.min(self.tri.volumes()) * scale_factor)
592+
n = max(10, int(0.658 / a_sq))
589593

590594
xs = ys = np.linspace(0, 1, n)
591595
xys = [xs[:, None], ys[None, :]]
@@ -780,7 +784,7 @@ def plot_isoline(self, level=0.0, n=None, tri_alpha=0):
780784
plot = plot * self.plot_isoline(level=l, n=-1)
781785
return plot
782786

783-
vertices, lines = self.self._get_iso(level, which='line')
787+
vertices, lines = self._get_iso(level, which='line')
784788
paths = [[vertices[i], vertices[j]] for i, j in lines]
785789
contour = hv.Path(paths)
786790

0 commit comments

Comments
 (0)