Skip to content

Commit

Permalink
Merge 0d6a0fb into 3658cbd
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Mar 16, 2017
2 parents 3658cbd + 0d6a0fb commit b5a5778
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
28 changes: 17 additions & 11 deletions holoviews/plotting/mpl/element.py
Expand Up @@ -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:
Expand All @@ -199,8 +196,11 @@ 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
if not (self.logx or self.logy):
if self.aspect is not None and self.projection != 'polar':
self._set_aspect(axis, self.aspect)

if not subplots and not self.drawn:
Expand Down Expand Up @@ -296,13 +296,19 @@ 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 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':
data_ratio = data_ratio/aspect
axes.set_aspect(data_ratio)


def _set_axis_limits(self, axis, view, subplots, ranges):
Expand Down
2 changes: 0 additions & 2 deletions holoviews/plotting/mpl/plot.py
Expand Up @@ -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)
Expand Down

0 comments on commit b5a5778

Please sign in to comment.