Skip to content

Commit

Permalink
Update aspect ratio detection to consider plot box aspect ratio too.
Browse files Browse the repository at this point in the history
Previously, only the data aspect ratio was considered when setting the
hatch angle.  For most plots with about a 3:4 ratio, this was not too
bad an approximation.  However, the pbaspect() function exists, so why
not use it.
  • Loading branch information
ramcdona committed Jun 17, 2021
1 parent 31856a1 commit 53ad7bf
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion hatchedline.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
% convention.
% 26 October 2020 v. 1.6 -- Added support for log-plots.
% 7 February 2021 v. 1.7 -- Fix bug with default axes and huge data.
% 16 June 2021 v. 1.8 -- Improve discovery of aspect ratio.

xlog = strcmp( get( gca, 'XScale' ), 'log' );
ylog = strcmp( get( gca, 'YScale' ), 'log' );
Expand Down Expand Up @@ -76,7 +77,14 @@
dyax = log( dyax );
end

ar = dyax / dxax;
ard = dyax / dxax;

% Plot aspect ratio (paper space)
pa = pbaspect( );
arp = pa( 2 ) / pa( 1 );

% Compute overall aspect ratio including data and paper influence
ar = ard / arp;
end

% Default tick spacing
Expand Down

0 comments on commit 53ad7bf

Please sign in to comment.