From 04562484d90ce0299ab37cef3fa39e13fdc7be0f Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Wed, 15 Mar 2017 22:48:45 +0000 Subject: [PATCH 1/5] Stopped forcing plots in Layout to square --- holoviews/plotting/mpl/plot.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/holoviews/plotting/mpl/plot.py b/holoviews/plotting/mpl/plot.py index ceae20c25a..eed4d04f16 100644 --- a/holoviews/plotting/mpl/plot.py +++ b/holoviews/plotting/mpl/plot.py @@ -984,8 +984,6 @@ def _create_subplots(self, layout, positions, layout_dimensions, ranges, axes={} own_params = self.get_param_values(onlychanged=True) sublabel_opts = {k: v for k, v in own_params if 'sublabel_' in k} - if not isinstance(view, GridSpace): - override_opts = dict(aspect='square') elif pos == 'right': right_opts = dict(invert_axes=True, xaxis=None) From 64e18a8311d84683a5aeb7bb862676aaad7cc8f8 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Wed, 15 Mar 2017 22:51:18 +0000 Subject: [PATCH 2/5] Correctly handle mpl semilog and loglog aspect ratios --- holoviews/plotting/mpl/element.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/holoviews/plotting/mpl/element.py b/holoviews/plotting/mpl/element.py index 0323f17361..cede73ad40 100644 --- a/holoviews/plotting/mpl/element.py +++ b/holoviews/plotting/mpl/element.py @@ -200,8 +200,7 @@ def _finalize_axis(self, key, title=None, dimensions=None, ranges=None, xticks=N self._finalize_ticks(axis, dimensions, xticks, yticks, zticks) # Apply aspects - if not (self.logx or self.logy): - self._set_aspect(axis, self.aspect) + self._set_aspect(axis, self.aspect) if not subplots and not self.drawn: self._finalize_artist(key) @@ -296,13 +295,22 @@ def _set_aspect(self, axes, aspect): """ Set the aspect on the axes based on the aspect setting. """ - if aspect and aspect == 'square': - axes.set_aspect((1./axes.get_data_ratio())) - elif aspect not in [None, 'square']: - if isinstance(aspect, util.basestring): - axes.set_aspect(aspect) - else: - axes.set_aspect(((1./axes.get_data_ratio()))/aspect) + if aspect is None: + return + elif isinstance(aspect, util.basestring) and aspect != 'square': + axes.set_aspect(aspect) + return + + (x0, x1), (y0, y1) = axes.get_xlim(), axes.get_ylim() + xsize = np.log(x1) - np.log(x0) if self.logx else x1-x0 + ysize = np.log(y1) - np.log(y0) if self.logy else y1-y0 + xsize = max(abs(xsize), 1e-30) + ysize = max(abs(ysize), 1e-30) + data_ratio = 1./(ysize/xsize) + if aspect == 'square': + axes.set_aspect(data_ratio) + else: + ax.set_aspect(data_ratio/aspect) def _set_axis_limits(self, axis, view, subplots, ranges): From ac3cd3a62696ddf6050dd8bea51220e9a362d291 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Wed, 15 Mar 2017 23:18:18 +0000 Subject: [PATCH 3/5] Set matplotlib axis ranges after ticks --- holoviews/plotting/mpl/element.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/holoviews/plotting/mpl/element.py b/holoviews/plotting/mpl/element.py index cede73ad40..c69c7248eb 100644 --- a/holoviews/plotting/mpl/element.py +++ b/holoviews/plotting/mpl/element.py @@ -174,9 +174,6 @@ def _finalize_axis(self, key, title=None, dimensions=None, ranges=None, xticks=N if dimensions: self._set_labels(axis, dimensions, xlabel, ylabel, zlabel) - # Set axes limits - self._set_axis_limits(axis, element, subplots, ranges) - if not subplots: legend = axis.get_legend() if legend: @@ -199,6 +196,9 @@ def _finalize_axis(self, key, title=None, dimensions=None, ranges=None, xticks=N if self.apply_ticks: self._finalize_ticks(axis, dimensions, xticks, yticks, zticks) + # Set axes limits + self._set_axis_limits(axis, element, subplots, ranges) + # Apply aspects self._set_aspect(axis, self.aspect) From 1bce5beb54614d7bdcbbdc715ba2f0c24dee9dbd Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Thu, 16 Mar 2017 01:33:35 +0000 Subject: [PATCH 4/5] Fixed small bug setting mpl aspect --- holoviews/plotting/mpl/element.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/holoviews/plotting/mpl/element.py b/holoviews/plotting/mpl/element.py index c69c7248eb..409a2b6160 100644 --- a/holoviews/plotting/mpl/element.py +++ b/holoviews/plotting/mpl/element.py @@ -307,10 +307,9 @@ def _set_aspect(self, axes, aspect): xsize = max(abs(xsize), 1e-30) ysize = max(abs(ysize), 1e-30) data_ratio = 1./(ysize/xsize) - if aspect == 'square': - axes.set_aspect(data_ratio) - else: - ax.set_aspect(data_ratio/aspect) + if aspect != 'square': + data_ratio = data_ratio/aspect + axes.set_aspect(data_ratio) def _set_axis_limits(self, axis, view, subplots, ranges): From 0d6a0fbe12e92bcc91c21cf1670c3548b47fd738 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Thu, 16 Mar 2017 12:16:52 +0000 Subject: [PATCH 5/5] Fixes for aspects on plots with projections --- holoviews/plotting/mpl/element.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/holoviews/plotting/mpl/element.py b/holoviews/plotting/mpl/element.py index 409a2b6160..a4aace0b39 100644 --- a/holoviews/plotting/mpl/element.py +++ b/holoviews/plotting/mpl/element.py @@ -200,7 +200,8 @@ def _finalize_axis(self, key, title=None, dimensions=None, ranges=None, xticks=N self._set_axis_limits(axis, element, subplots, ranges) # Apply aspects - self._set_aspect(axis, self.aspect) + if self.aspect is not None and self.projection != 'polar': + self._set_aspect(axis, self.aspect) if not subplots and not self.drawn: self._finalize_artist(key) @@ -295,9 +296,7 @@ def _set_aspect(self, axes, aspect): """ Set the aspect on the axes based on the aspect setting. """ - if aspect is None: - return - elif isinstance(aspect, util.basestring) and aspect != 'square': + if isinstance(aspect, util.basestring) and aspect != 'square': axes.set_aspect(aspect) return