-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
25f272a
commit 011eb57
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
function applyEqualAxes(axes_char) | ||
% APPLYEQUALAXES Apply equal aspect ratios desired axes. | ||
% | ||
% Usage: Select desired axes and type the command, | ||
% PlotDefaults.applyEqualAxes(axes_string) | ||
% where axes_string is a character array of axes to be equalised. | ||
% | ||
% Example: Set x-y axes to be equal | ||
% PlotDefaults.applyEqualAxes('xy') | ||
% | ||
% Example: Set x-z axes to be equal | ||
% PlotDefaults.applyEqualAxes('xz') | ||
% | ||
% Example: Set x-y-z axes to be equal | ||
% PlotDefaults.applyEqualAxes('xyz') | ||
% OR PlotDefaults.applyEqualAxes | ||
|
||
|
||
% Data select | ||
axesbool = [false, false, false]; | ||
|
||
% Validate arguments | ||
if nargin > 0 | ||
validchar = ~isempty(axes_char) && length(axes_char) <= 3 && ischar(axes_char); | ||
|
||
if ~validchar | ||
error('Invalid input: must be char of length less than 3') | ||
end | ||
|
||
for i = 1:length(axes_char) | ||
axesbool = axesbool | strcmp(axes_char(i), {'x', 'y', 'z'}); | ||
end | ||
|
||
if ~any(find(axesbool)) | ||
warning('No valid input. Char must contain x, y or z') | ||
end | ||
else | ||
axesbool = [1, 1, 1]; | ||
end | ||
|
||
% Fetch current data aspect ratio | ||
ax = gca; | ||
|
||
% Fetch maximum desired aspect ratio | ||
D = ax.DataAspectRatio(axesbool); | ||
|
||
% Apply equal axes to each | ||
ax.DataAspectRatio(axesbool) = max(D); | ||
|
||
|
||
|
||
end |