subfig

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Visualization
Introduced first in SolidGeometry 4.2, Creation date: 2018-07-25, Last change: 2025-09-14

creates subfigures on the screen similar to subplot



See Also: copyfig

Example Illustration

 missing image of subfig (p)

Syntax

subfig([p])

Input Parameter

p: position similar to subplot

Examples


for i=1:4; SGfigure(SGbox([30,20,10])); view(-30,30);end
for i=1:4; SGfigure(SGbox([30,20,10])); view(-30,30); copyfig; end
for i=1:4; SGfigure(SGbox([30,20,10])); view(-30,30); copyfig; subfig(i); end




Copyright 2018-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, subfig, is designed to create subfigures on the screen similar to the subplot function in MATLAB. It is part of the SolidGeometry library and was introduced in version 4.2.

Input Parameters

Algorithm Steps

  1. Initialize a variable delta with a value of 50. This is used to adjust the screen size and figure size.
  2. Check the number of input arguments. If one argument is provided, assign it to p. Otherwise, set p to 1.
  3. Retrieve the screen size using get(get(gcf,'Parent'),'ScreenSize') and adjust the width by subtracting delta.
  4. Get the current figure's position and outer position using get(gcf,'Position') and get(gcf,'OuterPosition'), then adjust the height by subtracting delta.
  5. Calculate the number of columns c and rows r that can fit on the screen by dividing the screen width and height by the figure's width and height, respectively.
  6. Determine the maximum number of figures nmax that can fit on the screen as the product of r and c.
  7. Use the mod1 function to adjust p within the range of nmax.
  8. Calculate the horizontal and vertical spacing dx and dy between figures.
  9. Determine the column x and row y for the figure based on p.
  10. Calculate the new position [sx, sy] for the figure on the screen.
  11. Move the current figure to the calculated position using movegui(gcf,[sx sy]).
  12. Pause briefly and then call show to update the display.
Algorithm explaination created using ChatGPT on 2025-08-19 00:37. (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