Repository: holoviz/holoviews
Pull request #6274 (2024-06-10 14:20:52)

Fix issue with range lookups in (y)-axis creation
An issue introduced by https://github.com/holoviz/holoviews/pull/6262 where the dimension was not correctly looked up.

Also makes a change to more robustly look up overlay dimensions on subplots (sorry for sneaking that in here).

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/holoviz/holoviews/pull/6274?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=holoviz) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 88.50%. Comparing base [(`7e5b515`)](https://app.codecov.io/gh/holoviz/holoviews/commit/7e5b5154981a97e5a450d2791f1e77de80fde5d8?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=holoviz) to head [(`afcd7ab`)](https://app.codecov.io/gh/holoviz/holoviews/commit/afcd7ab47c6694f8f952e1524996b87ccb9fb040?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=holoviz).
> Report is 2 commits behind head on main.


<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##             main    #6274      +/-   ##
==========================================
- Coverage   88.53%   88.50%   -0.04%     
==========================================
  Files         323      323              
  Lines       67934    67959      +25     
==========================================
- Hits        60146    60145       -1     
- Misses       7788     7814      +26     
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/holoviz/holoviews/pull/6274?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=holoviz).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=holoviz).

philippjfr: Test would be nice. Will take a look shortly.

Patch:
diff --git a/holoviews/plotting/bokeh/element.py b/holoviews/plotting/bokeh/element.py
index 8015bd1e6..f5fea8f2b 100644
--- a/holoviews/plotting/bokeh/element.py
+++ b/holoviews/plotting/bokeh/element.py
@@ -721,7 +721,7 @@ class ElementPlot(BokehPlot, GenericElementPlot):
         elif pos == 1 and dim:
             dims = [dim]
             v0, v1 = util.max_range([
-                elrange.get(dim.name, {'combined': (None, None)})['combined']
+                elrange.get(dim.label, {'combined': (None, None)})['combined']
                 for elrange in ranges.values()
             ])
             axis_label = str(dim)
@@ -843,7 +843,7 @@ class ElementPlot(BokehPlot, GenericElementPlot):
             if self._subcoord_overlaid:
                 if opts.get('subcoordinate_y') is None:
                     continue
-                if element.kdims:
+                if sp.overlay_dims:
                     ax_name = ', '.join(d.pprint_value(k) for d, k in zip(element.kdims, sp_key))
                 else:
                     ax_name = el.label


Test patch:
diff --git a/holoviews/tests/plotting/bokeh/test_overlayplot.py b/holoviews/tests/plotting/bokeh/test_overlayplot.py
index bfca27b19..8f1e989eb 100644
--- a/holoviews/tests/plotting/bokeh/test_overlayplot.py
+++ b/holoviews/tests/plotting/bokeh/test_overlayplot.py
@@ -287,6 +287,45 @@ class TestOverlayPlot(LoggingComparisonTestCase, TestBokehPlot):
         assert plot.batched == False
         assert len(plot.subplots) == 10
 
+    def test_ndoverlay_subcoordinate_y_ranges(self):
+        data = {
+            'x': np.arange(10),
+            'A': np.arange(10),
+            'B': np.arange(10)*2,
+            'C': np.arange(10)*3
+        }
+        overlay = NdOverlay({
+            'A': Curve(data, 'x', ('A', 'y')).opts(subcoordinate_y=True),
+            'B': Curve(data, 'x', ('B', 'y')).opts(subcoordinate_y=True),
+            'C': Curve(data, 'x', ('C', 'y')).opts(subcoordinate_y=True),
+        })
+        plot = bokeh_renderer.get_plot(overlay)
+
+        assert plot.state.y_range.start == -0.5
+        assert plot.state.y_range.end == 2.5
+        for sp in plot.subplots.values():
+            assert sp.handles['y_range'].start == 0
+            assert sp.handles['y_range'].end == 27
+
+    def test_overlay_subcoordinate_y_ranges(self):
+        data = {
+            'x': np.arange(10),
+            'A': np.arange(10),
+            'B': np.arange(10)*2,
+            'C': np.arange(10)*3
+        }
+        overlay = Overlay([
+            Curve(data, 'x', ('A', 'y'), label='A').opts(subcoordinate_y=True),
+            Curve(data, 'x', ('B', 'y'), label='B').opts(subcoordinate_y=True),
+            Curve(data, 'x', ('C', 'y'), label='C').opts(subcoordinate_y=True),
+        ])
+        plot = bokeh_renderer.get_plot(overlay)
+
+        assert plot.state.y_range.start == -0.5
+        assert plot.state.y_range.end == 2.5
+        for sp in plot.subplots.values():
+            assert sp.handles['y_range'].start == 0
+            assert sp.handles['y_range'].end == 27
 
 
 class TestLegends(TestBokehPlot):