Syntax
[n,subs]=subplotnumber([fig])
Input Parameter
Output Parameter
n : | | number of subplots |
subs : | | list of handles |
Examples
PLsample; subplotnumber
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, subplotnumber
, is designed to determine the number of subplot axes present in a given figure. It is part of the SolidGeometry library and was introduced in version 5.1. The function can be used to retrieve both the count of subplots and their respective handles.
Input Parameters
- fig: This parameter represents the figure handle. If not provided, the function defaults to using the current figure (
gcf
).
Output Results
- n: The number of subplot axes found within the specified figure.
- subs: A list of handles corresponding to each subplot axis.
Algorithm Steps
- The function begins by determining the figure to be analyzed. It uses the helper function
getfuncparams
to retrieve the first argument from varargin
, defaulting to gcf
if no argument is provided.
- It then identifies all child objects of the specified figure that are of type 'Axes' using the
findobj
function. This effectively filters out all subplot axes within the figure.
- The number of subplot axes is calculated using
numel
, which counts the elements in the subs
array.
- The function returns the count of subplots (
n
) and the list of subplot handles (subs
).
Example Usage
To use this function, you can call it after creating a figure with subplots. For instance:
PLsample; subplotnumber
This will return the number of subplots and their handles for the current figure.
Algorithm explaination created using ChatGPT on 2025-08-18 22:21. (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