Browse code

fix plotting resolution for larger scaled learnerND

Jorn Hoofwijk authored on 07/12/2018 09:36:21 • Bas Nijholt committed on 07/12/2018 17:06:03
Showing 1 changed files
... ...
@@ -506,7 +506,7 @@ class LearnerND(BaseLearner):
506 506
         if self.vdim > 1:
507 507
             raise NotImplementedError('holoviews currently does not support',
508 508
                                       '3D surface plots in bokeh.')
509
-        if len(self.ndim) != 2:
509
+        if self.ndim != 2:
510 510
             raise NotImplementedError("Only 2D plots are implemented: You can "
511 511
                                       "plot a 2D slice with 'plot_slice'.")
512 512
         x, y = self._bbox
... ...
@@ -516,7 +516,9 @@ class LearnerND(BaseLearner):
516 516
             if n is None:
517 517
                 # Calculate how many grid points are needed.
518 518
                 # 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))
520 522
 
521 523
             xs = ys = np.linspace(0, 1, n)
522 524
             xs = xs * (x[1] - x[0]) + x[0]
... ...
@@ -585,7 +587,9 @@ class LearnerND(BaseLearner):
585 587
             if n is None:
586 588
                 # Calculate how many grid points are needed.
587 589
                 # 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))
589 593
 
590 594
             xs = ys = np.linspace(0, 1, n)
591 595
             xys = [xs[:, None], ys[None, :]]
... ...
@@ -780,7 +784,7 @@ class LearnerND(BaseLearner):
780 784
                 plot = plot * self.plot_isoline(level=l, n=-1)
781 785
             return plot
782 786
 
783
-        vertices, lines = self.self._get_iso(level, which='line')
787
+        vertices, lines = self._get_iso(level, which='line')
784 788
         paths = [[vertices[i], vertices[j]] for i, j in lines]
785 789
         contour = hv.Path(paths)
786 790