axisratio

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Visualization
Introduced first in SolidGeometry 5.0, Creation date: 2021-02-09, Last change: 2025-08-18

returns the axis ratio x y z



See Also: , axis4math , axis4animation , axisscale , axis4all

Example Illustration

 missing image of axisratio

Syntax

ar=axisratio

Output Parameter

ar: [1 y/x z/x]

Examples


figure; view(-30,30); SGplotalpha(SGbox); axisratio




Copyright 2021-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

This function, named axisratio, calculates the axis ratio of a plot in MATLAB. It is part of the SolidGeometry library and was introduced in version 5.0. The function does not take any input parameters and returns a vector ar as output.

Input Parameters

The function does not require any input parameters.

Output

The output ar is a vector that contains the axis ratios. Specifically, it returns a vector in the form [1, y/x, z/x], where y/x is the ratio of the y-axis length to the x-axis length, and z/x is the ratio of the z-axis length to the x-axis length if a third dimension is present.

Algorithm Steps

  1. The function retrieves the current axis limits using the axis command, which returns a vector ax containing the limits of the x, y, and possibly z axes.
  2. It calculates the difference between the maximum and minimum x-axis limits, dx = ax(2) - ax(1).
  3. It calculates the difference between the maximum and minimum y-axis limits, dy = ax(4) - ax(3).
  4. The function initializes the output vector ar with the value [1, dy/dx], representing the ratio of the y-axis to the x-axis.
  5. If the axis vector ax contains more than four elements, it indicates the presence of a z-axis. The function then calculates the difference between the maximum and minimum z-axis limits, dz = ax(6) - ax(5).
  6. The function appends the z-axis ratio dz/dx to the output vector ar, resulting in [1, dy/dx, dz/dx].

Example Usage

An example of how to use the function is provided in the comments:

figure; 
view(-30,30); 
SGplotalpha(SGbox); 
axisratio

This example creates a figure, sets the view, plots a box using the SGplotalpha function, and then calls axisratio to calculate and display the axis ratios.

Algorithm explaination created using ChatGPT on 2025-08-18 22:09. (Please note: No guarantee for the correctness of this explanation)

Last html export of this page out of FM database by TL: 2025-09-21