Skip to content

Commit

Permalink
Add plot option to transpose layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Feb 5, 2017
1 parent 68c6af8 commit 6eeebc4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion holoviews/plotting/bokeh/plot.py
Expand Up @@ -361,7 +361,7 @@ def _init_layout(self, layout):
layout_subplots, layouts, paths = {}, {}, {}
for r, c in self.coords:
# Get view at layout position and wrap in AdjointLayout
key, view = layout_items.get((r, c), (None, None))
key, view = layout_items.get((c, r) if self.transpose else (r, c), (None, None))
view = view if isinstance(view, AdjointLayout) else AdjointLayout([view])
layouts[(r, c)] = view
paths[r, c] = key
Expand Down
2 changes: 1 addition & 1 deletion holoviews/plotting/mpl/plot.py
Expand Up @@ -730,7 +730,7 @@ def _compute_gridspec(self, layout):
col_widthratios, row_heightratios = {}, {}
for (r, c) in self.coords:
# Get view at layout position and wrap in AdjointLayout
_, view = layout_items.get((r, c), (None, None))
_, view = layout_items.get((c, r) if self.transpose else (r, c), (None, None))
layout_view = view if isinstance(view, AdjointLayout) else AdjointLayout([view])
layouts[(r, c)] = layout_view

Expand Down
5 changes: 4 additions & 1 deletion holoviews/plotting/plot.py
Expand Up @@ -1030,6 +1030,9 @@ class GenericLayoutPlot(GenericCompositePlot):
displays the elements in a cartesian grid in scanline order.
"""

transpose = param.Boolean(default=False, doc="""
Whether to transpose the layout when plotting""")

def __init__(self, layout, **params):
if not isinstance(layout, (NdLayout, Layout)):
raise ValueError("GenericLayoutPlot only accepts Layout objects.")
Expand All @@ -1038,6 +1041,6 @@ def __init__(self, layout, **params):

super(GenericLayoutPlot, self).__init__(layout, **params)
self.subplots = {}
self.rows, self.cols = layout.shape
self.rows, self.cols = layout.shape[::-1] if self.transpose else layout.shape
self.coords = list(product(range(self.rows),
range(self.cols)))
2 changes: 1 addition & 1 deletion holoviews/plotting/plotly/plot.py
Expand Up @@ -66,7 +66,7 @@ def _init_layout(self, layout):
inserts_cols = []
for r, c in self.coords:
# Get view at layout position and wrap in AdjointLayout
key, view = layout_items.get((r, c), (None, None))
key, view = layout_items.get((c, r) if self.transpose else (r, c), (None, None))
view = view if isinstance(view, AdjointLayout) else AdjointLayout([view])
layouts[(r, c)] = view
paths[r, c] = key
Expand Down

0 comments on commit 6eeebc4

Please sign in to comment.