Skip to content

Commit

Permalink
Calculate aspect ratio for DataAxis
Browse files Browse the repository at this point in the history
  • Loading branch information
pietsjoh committed Aug 9, 2023
1 parent 29d89d4 commit 38c8cc0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions hyperspy/drawing/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,16 @@ def _calculate_aspect(self):
factor = min_asp ** -1 * xaxis.size / yaxis.size
self._auto_scalebar = False
self._auto_axes_ticks = True
if xaxis.is_uniform and yaxis.is_uniform:
self._aspect = abs(factor * xaxis.scale / yaxis.scale)
## TODO: implement this for functional axis
if xaxis.is_uniform:
xscale = xaxis.scale
else:
xscale = (xaxis.axis[-1] - xaxis.axis[0]) / xaxis.size
if yaxis.is_uniform:
yscale = yaxis.scale
else:
self._aspect = 1.0
yscale = (yaxis.axis[-1] - yaxis.axis[0]) / yaxis.size
self._aspect = abs(factor * xscale / yscale)

def _calculate_vmin_max(self, data, auto_contrast=False,
vmin=None, vmax=None):
Expand Down

0 comments on commit 38c8cc0

Please sign in to comment.