Skip to content

Commit

Permalink
Improved width/height scaling algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Feb 27, 2017
1 parent c622946 commit 99cb913
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions holoviews/plotting/bokeh/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def layout_padding(plots, renderer):

def make_axis(axis, size, factors, dim, flip=False, rotation=0):
factors = list(map(dim.pprint_value, factors))
nchars = np.max([len(f) for f in factors])
ranges = FactorRange(factors=factors)
ranges2 = Range1d(start=0, end=1)
axis_label = dim_axis_label(dim)
Expand All @@ -170,14 +171,14 @@ def make_axis(axis, size, factors, dim, flip=False, rotation=0):
if axis == 'x':
align = 'center'
# Adjust height to compensate for label rotation
height = int(50 + np.abs(np.sin(rotation)) * 30)
height = int(50 + np.abs(np.sin(rotation)) * (nchars*8))
opts = dict(x_axis_type='auto', x_axis_label=axis_label,
x_range=ranges, y_range=ranges2, plot_height=height,
plot_width=size)
else:
# Adjust width to compensate for label rotation
align = 'left' if flip else 'right'
width = int(80 - np.abs(np.sin(rotation)) * 30)
width = int(50 + np.abs(np.cos(rotation)) * (nchars*8))
opts = dict(y_axis_label=axis_label, x_range=ranges2,
y_range=ranges, plot_width=width, plot_height=size)

Expand Down
2 changes: 1 addition & 1 deletion tests/testrenderclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def test_get_size_grid_plot(self):
grid = GridSpace({(i, j): self.image1 for i in range(3) for j in range(3)})
plot = self.renderer.get_plot(grid)
w, h = self.renderer.get_size(plot)
self.assertEqual((w, h), (440, 410))
self.assertEqual((w, h), (418, 410))

def test_get_size_table(self):
table = Table(range(10), kdims=['x'])
Expand Down

0 comments on commit 99cb913

Please sign in to comment.