copyfig
by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - User interface
Introduced first in SolidGeometry 4.0, Creation date: 2017-08-03, Last change: 2025-09-14
copies a axis diagramm into a new MATLAB figure
Description
Menue, colors, grid, etc. are not copied.
See Also: copyplot
, snapplot
, subfig
, pushgcf
, popgcf
Example Illustration
Syntax
nf=copyfig([cf,nf])
Input Parameter
cf: | | copy figure handle; default is gcf/gca |
nf: | | optional number/handle to figure to copy to. |
Output Parameter
Examples
SGfigure(SGsample(27)); view(-30,30);
copyfig
Copyright 2017-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)
The function copyfig is designed to copy the contents of a specified figure or the current figure to a new figure in MATLAB. It does not copy menu settings, colors, or grid settings.
Input Parameters
- cf: The handle of the figure to copy. If not provided, it defaults to the current figure (
gcf).
- nf: An optional handle or number for the new figure. If not provided, a new figure is created.
Output
- nf: The handle of the new figure.
Algorithm Steps
- Retrieve the figure handle
cf from the input parameters or default to gcf.
- Retrieve the new figure handle
nf from the input parameters or initialize it as an empty string.
- Get the visibility status of the figure
cf.
- If the current figure is not
cf, make cf the current figure and set its visibility.
- Get the current view angles
(a, b) of the axes.
- Retrieve the title object of the current axes.
- Get the current axes handle
ca.
- If
nf is empty, create a new figure and assign it to nf. Otherwise, make nf the current figure.
- Set the visibility of
nf to match cf.
- Create new axes
na in the new figure and set the colormap and color limits.
- Copy all child objects from the current axes
ca to the new axes na.
- Set the axis properties to be tight, equal, and turn on the grid and axis.
- Set the view of the new axes to match the original view angles
(a, b).
- Enable 3D rotation for the new figure.
- Move the new figure window to the northeast position on the screen.
- Set the title of the new axes to match the original title, without interpreting special characters.
- Call
SGtitle with an empty string and 'window' as parameters.
Algorithm explaination created using ChatGPT on 2025-08-19 01: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