Skip to content

Commit

Permalink
Allow setting GridPlot.plot_size as tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Mar 22, 2019
1 parent 45bbb4a commit e466eff
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions holoviews/plotting/bokeh/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,10 @@ class GridPlot(CompositePlot, GenericCompositePlot):
yrotation = param.Integer(default=0, bounds=(0, 360), doc="""
Rotation angle of the yticks.""")

plot_size = param.Integer(default=120, doc="""
Defines the width and height of each plot in the grid""")
plot_size = param.ClassSelector(default=120, class_=(int, tuple), doc="""
Defines the width and height of each plot in the grid, either
as a tuple specifying width and height or an integer for a
square plot.""")

def __init__(self, layout, ranges=None, layout_num=1, keys=None, **params):
if not isinstance(layout, GridSpace):
Expand All @@ -596,6 +598,11 @@ def __init__(self, layout, ranges=None, layout_num=1, keys=None, **params):


def _create_subplots(self, layout, ranges):
if isinstance(self.plot_size, tuple):
width, height = self.plot_size
else:
width, height = self.plot_size, self.plot_size

subplots = OrderedDict()
frame_ranges = self.compute_ranges(layout, None, ranges)
keys = self.keys[:1] if self.dynamic else self.keys
Expand All @@ -622,8 +629,10 @@ def _create_subplots(self, layout, ranges):

# Create axes
kwargs = {}
kwargs['frame_width'] = self.plot_size
kwargs['frame_height'] = self.plot_size
if width is not None:
kwargs['frame_width'] = width
if height is not None:
kwargs['frame_height'] = height
if c == 0 and r != 0:
kwargs['xaxis'] = None
if c != 0 and r == 0:
Expand Down

0 comments on commit e466eff

Please sign in to comment.