Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use correct dpi in MPLRenderer.get_size #1143

Merged
merged 1 commit into from
Feb 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions holoviews/plotting/mpl/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ def plot_options(cls, obj, percent_size):
@bothmethod
def get_size(self_or_cls, plot):
w, h = plot.state.get_size_inches()
dpi = plot.state.dpi
return (w*dpi, h*dpi)
dpi = self_or_cls.dpi if self_or_cls.dpi else plot.state.dpi
return (int(w*dpi), int(h*dpi))


def diff(self, plot):
Expand Down
32 changes: 32 additions & 0 deletions tests/testrenderclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,38 @@ def test_export_widgets(self):
self.assertEqual(digest_data(data),
'91bbc7b4efebd07b1ee595b902d9899b27f2c7e353dfc87c57c2dfd5d0404301')

def test_get_size_single_plot(self):
plot = self.renderer.get_plot(self.image1)
w, h = self.renderer.get_size(plot)
self.assertEqual((w, h), (400, 400))

def test_get_size_row_plot(self):
plot = self.renderer.get_plot(self.image1+self.image2)
w, h = self.renderer.get_size(plot)
self.assertEqual((w, h), (800, 355))

def test_get_size_column_plot(self):
plot = self.renderer.get_plot((self.image1+self.image2).cols(1))
w, h = self.renderer.get_size(plot)
self.assertEqual((w, h), (400, 702))

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), (480, 480))

def test_get_size_table(self):
table = Table(range(10), kdims=['x'])
plot = self.renderer.get_plot(table)
w, h = self.renderer.get_size(plot)
self.assertEqual((w, h), (400, 400))

def test_get_size_tables_in_layout(self):
table = Table(range(10), kdims=['x'])
plot = self.renderer.get_plot(table+table)
w, h = self.renderer.get_size(plot)
self.assertEqual((w, h), (800, 320))

class BokehRendererTest(ComparisonTestCase):

Expand Down