From 181e0dca8ddef89844b4143cbc10f238be5d9e63 Mon Sep 17 00:00:00 2001
From: Philipp Rudiger
Date: Wed, 31 Aug 2016 20:00:35 +0100
Subject: [PATCH 1/6] Cleaned up CompositePlot instantiation
---
holoviews/plotting/bokeh/plot.py | 22 +++-------------------
holoviews/plotting/mpl/plot.py | 18 ++----------------
holoviews/plotting/plot.py | 30 ++++++++++++++++++------------
3 files changed, 23 insertions(+), 47 deletions(-)
diff --git a/holoviews/plotting/bokeh/plot.py b/holoviews/plotting/bokeh/plot.py
index 1c6be8b54c..2eacd5cb50 100644
--- a/holoviews/plotting/bokeh/plot.py
+++ b/holoviews/plotting/bokeh/plot.py
@@ -164,27 +164,11 @@ class GridPlot(BokehPlot, GenericCompositePlot):
object.
"""
- def __init__(self, layout, ranges=None, keys=None, dimensions=None,
- layout_num=1, **params):
+ def __init__(self, layout, ranges=None, **params):
if not isinstance(layout, GridSpace):
raise Exception("GridPlot only accepts GridSpace.")
-
- self.layout = layout
- self.rows, self.cols = layout.shape
- self.layout_num = layout_num
- extra_opts = self.lookup_options(layout, 'plot').options
- if not keys or not dimensions:
- dimensions, keys = traversal.unique_dimkeys(layout)
- if 'uniform' not in params:
- params['uniform'] = traversal.uniform(layout)
-
- dynamic, sampled = get_dynamic_mode(layout)
- if sampled:
- initialize_sampled(layout, dimensions, keys[0])
-
- super(GridPlot, self).__init__(keys=keys, dimensions=dimensions,
- dynamic=dynamic,
- **dict(extra_opts, **params))
+ super(GridPlot, self).__init__(layout=layout, ranges=ranges,
+ **params)
self.subplots, self.layout = self._create_subplots(layout, ranges)
diff --git a/holoviews/plotting/mpl/plot.py b/holoviews/plotting/mpl/plot.py
index 274fa3ad32..f04808cb90 100644
--- a/holoviews/plotting/mpl/plot.py
+++ b/holoviews/plotting/mpl/plot.py
@@ -280,24 +280,10 @@ class GridPlot(CompositePlot):
yrotation = param.Integer(default=0, bounds=(0, 360), doc="""
Rotation angle of the yticks.""")
- def __init__(self, layout, axis=None, create_axes=True, ranges=None,
- keys=None, dimensions=None, layout_num=1, **params):
+ def __init__(self, layout, axis=None, create_axes=True, ranges=None, **params):
if not isinstance(layout, GridSpace):
raise Exception("GridPlot only accepts GridSpace.")
- self.layout = layout
- self.cols, self.rows = layout.shape
- self.layout_num = layout_num
- extra_opts = self.lookup_options(layout, 'plot').options
- if not keys or not dimensions:
- dimensions, keys = traversal.unique_dimkeys(layout)
- if 'uniform' not in params:
- params['uniform'] = traversal.uniform(layout)
- dynamic, sampled = get_dynamic_mode(layout)
- if sampled:
- initialize_sampled(layout, dimensions, keys[0])
- super(GridPlot, self).__init__(keys=keys, dimensions=dimensions,
- dynamic=dynamic,
- **dict(extra_opts, **params))
+ super(GridPlot, self).__init__(layout, ranges=ranges, **params)
# Compute ranges layoutwise
grid_kwargs = {}
if axis is not None:
diff --git a/holoviews/plotting/plot.py b/holoviews/plotting/plot.py
index 71e2b0f2d3..fb10806107 100644
--- a/holoviews/plotting/plot.py
+++ b/holoviews/plotting/plot.py
@@ -883,6 +883,23 @@ def get_extents(self, overlay, ranges):
class GenericCompositePlot(DimensionedPlot):
+ def __init__(self, layout, keys=None, dimensions=None, **params):
+ dynamic, sampled = get_dynamic_mode(layout)
+ if sampled:
+ initialize_sampled(layout, dimensions, keys[0])
+ if not keys:
+ dimensions, keys = traversal.unique_dimkeys(layout)
+ if 'uniform' not in params:
+ params['uniform'] = traversal.uniform(layout)
+
+ self.layout = layout
+ self.rows, self.cols = layout.shape
+ super(GenericCompositePlot, self).__init__(composite, keys=keys,
+ dynamic=dynamic,
+ dimensions=dimensions,
+ **params)
+
+
def _get_frame(self, key):
"""
Creates a clone of the Layout with the nth-frame for each
@@ -956,18 +973,7 @@ def __init__(self, layout, **params):
if len(layout.values()) == 0:
raise ValueError("Cannot display empty layout")
- self.layout = layout
+ super(GenericLayoutPlot, self).__init__(**params)
self.subplots = {}
- self.rows, self.cols = layout.shape
self.coords = list(product(range(self.rows),
range(self.cols)))
- dynamic, sampled = get_dynamic_mode(layout)
- dimensions, keys = traversal.unique_dimkeys(layout)
- if sampled:
- initialize_sampled(layout, dimensions, keys[0])
-
- uniform = traversal.uniform(layout)
- plotopts = self.lookup_options(layout, 'plot').options
- super(GenericLayoutPlot, self).__init__(keys=keys, dimensions=dimensions,
- uniform=uniform, dynamic=dynamic,
- **dict(plotopts, **params))
From cbcb6dec43c10f276cbff6b39c54d9d99d249da5 Mon Sep 17 00:00:00 2001
From: Philipp Rudiger
Date: Wed, 31 Aug 2016 20:11:10 +0100
Subject: [PATCH 2/6] Restored GridPlot layout_num default argument
---
holoviews/plotting/bokeh/plot.py | 6 +++---
holoviews/plotting/mpl/plot.py | 6 ++++--
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/holoviews/plotting/bokeh/plot.py b/holoviews/plotting/bokeh/plot.py
index 2eacd5cb50..e720a9ed3b 100644
--- a/holoviews/plotting/bokeh/plot.py
+++ b/holoviews/plotting/bokeh/plot.py
@@ -164,11 +164,11 @@ class GridPlot(BokehPlot, GenericCompositePlot):
object.
"""
- def __init__(self, layout, ranges=None, **params):
+ def __init__(self, layout, ranges=None, layout_num=1, **params):
if not isinstance(layout, GridSpace):
raise Exception("GridPlot only accepts GridSpace.")
- super(GridPlot, self).__init__(layout=layout, ranges=ranges,
- **params)
+ super(GridPlot, self).__init__(layout=layout, layout_num=layout_num,
+ ranges=ranges, **params)
self.subplots, self.layout = self._create_subplots(layout, ranges)
diff --git a/holoviews/plotting/mpl/plot.py b/holoviews/plotting/mpl/plot.py
index f04808cb90..8c48ce38e5 100644
--- a/holoviews/plotting/mpl/plot.py
+++ b/holoviews/plotting/mpl/plot.py
@@ -280,10 +280,12 @@ class GridPlot(CompositePlot):
yrotation = param.Integer(default=0, bounds=(0, 360), doc="""
Rotation angle of the yticks.""")
- def __init__(self, layout, axis=None, create_axes=True, ranges=None, **params):
+ def __init__(self, layout, axis=None, create_axes=True, ranges=None,
+ layout_num=1, **params):
if not isinstance(layout, GridSpace):
raise Exception("GridPlot only accepts GridSpace.")
- super(GridPlot, self).__init__(layout, ranges=ranges, **params)
+ super(GridPlot, self).__init__(layout, layout_num=layout_num,
+ ranges=ranges, **params)
# Compute ranges layoutwise
grid_kwargs = {}
if axis is not None:
From 7301e147e927bf073db7b74ee890ef5a08524bdd Mon Sep 17 00:00:00 2001
From: Philipp Rudiger
Date: Wed, 31 Aug 2016 20:15:38 +0100
Subject: [PATCH 3/6] Fixed GenericLayoutPlot
---
holoviews/plotting/plot.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/holoviews/plotting/plot.py b/holoviews/plotting/plot.py
index fb10806107..f25d08a00c 100644
--- a/holoviews/plotting/plot.py
+++ b/holoviews/plotting/plot.py
@@ -973,7 +973,7 @@ def __init__(self, layout, **params):
if len(layout.values()) == 0:
raise ValueError("Cannot display empty layout")
- super(GenericLayoutPlot, self).__init__(**params)
+ super(GenericLayoutPlot, self).__init__(layout, **params)
self.subplots = {}
self.coords = list(product(range(self.rows),
range(self.cols)))
From 3fbda58cf73c729168330673283953611b20a039 Mon Sep 17 00:00:00 2001
From: Philipp Rudiger
Date: Wed, 31 Aug 2016 20:21:00 +0100
Subject: [PATCH 4/6] Fixed GenericCompositePlot
---
holoviews/plotting/plot.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/holoviews/plotting/plot.py b/holoviews/plotting/plot.py
index f25d08a00c..d09fc28be6 100644
--- a/holoviews/plotting/plot.py
+++ b/holoviews/plotting/plot.py
@@ -894,7 +894,7 @@ def __init__(self, layout, keys=None, dimensions=None, **params):
self.layout = layout
self.rows, self.cols = layout.shape
- super(GenericCompositePlot, self).__init__(composite, keys=keys,
+ super(GenericCompositePlot, self).__init__(layout, keys=keys,
dynamic=dynamic,
dimensions=dimensions,
**params)
From 673c6bc3ad32d9555bfba8766e84755c996f2b8d Mon Sep 17 00:00:00 2001
From: Philipp Rudiger
Date: Wed, 31 Aug 2016 20:43:00 +0100
Subject: [PATCH 5/6] Small fixes for plot key/dimension initialization
---
holoviews/plotting/plot.py | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/holoviews/plotting/plot.py b/holoviews/plotting/plot.py
index d09fc28be6..5d70a04f86 100644
--- a/holoviews/plotting/plot.py
+++ b/holoviews/plotting/plot.py
@@ -547,9 +547,12 @@ def __init__(self, element, keys=None, ranges=None, dimensions=None,
if self.batched:
plot_element = plot_element.last
+ subplot = not keys
+ if subplot:
+ dimensions = self.hmap.kdims
+ keys = list(self.hmap.data.keys())
+
self.style = self.lookup_options(plot_element, 'style') if style is None else style
- dimensions = self.hmap.kdims if dimensions is None else dimensions
- keys = keys if keys else list(self.hmap.data.keys())
plot_opts = self.lookup_options(plot_element, 'plot').options
dynamic = False if not isinstance(element, DynamicMap) or element.sampled else element.mode
@@ -887,14 +890,17 @@ def __init__(self, layout, keys=None, dimensions=None, **params):
dynamic, sampled = get_dynamic_mode(layout)
if sampled:
initialize_sampled(layout, dimensions, keys[0])
- if not keys:
- dimensions, keys = traversal.unique_dimkeys(layout)
+
if 'uniform' not in params:
params['uniform'] = traversal.uniform(layout)
+ subplot = not keys
+ if subplot:
+ dimensions, keys = traversal.unique_dimkeys(layout)
+
self.layout = layout
self.rows, self.cols = layout.shape
- super(GenericCompositePlot, self).__init__(layout, keys=keys,
+ super(GenericCompositePlot, self).__init__(keys=keys,
dynamic=dynamic,
dimensions=dimensions,
**params)
From c12bc4bb9c97d37c6d737eb617c8e11cb53d4fb2 Mon Sep 17 00:00:00 2001
From: Philipp Rudiger
Date: Wed, 31 Aug 2016 20:43:32 +0100
Subject: [PATCH 6/6] AdjointPlot no longer subclassing CompositePlot
---
holoviews/plotting/bokeh/plot.py | 2 +-
holoviews/plotting/mpl/plot.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/holoviews/plotting/bokeh/plot.py b/holoviews/plotting/bokeh/plot.py
index e720a9ed3b..95de111dc6 100644
--- a/holoviews/plotting/bokeh/plot.py
+++ b/holoviews/plotting/bokeh/plot.py
@@ -532,7 +532,7 @@ def update_frame(self, key, ranges=None):
subplot.update_frame(key, ranges)
-class AdjointLayoutPlot(BokehPlot, GenericCompositePlot):
+class AdjointLayoutPlot(BokehPlot):
layout_dict = {'Single': {'positions': ['main']},
'Dual': {'positions': ['main', 'right']},
diff --git a/holoviews/plotting/mpl/plot.py b/holoviews/plotting/mpl/plot.py
index 8c48ce38e5..6c3a10a1c8 100644
--- a/holoviews/plotting/mpl/plot.py
+++ b/holoviews/plotting/mpl/plot.py
@@ -554,7 +554,7 @@ def _adjust_subplots(self, axis, subaxes):
-class AdjointLayoutPlot(CompositePlot):
+class AdjointLayoutPlot(MPLPlot):
"""
LayoutPlot allows placing up to three Views in a number of
predefined and fixed layouts, which are defined by the layout_dict