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

 missing image of copyfig(cf,nf)

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

nf: new figure handle

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

Output

Algorithm Steps

  1. Retrieve the figure handle cf from the input parameters or default to gcf.
  2. Retrieve the new figure handle nf from the input parameters or initialize it as an empty string.
  3. Get the visibility status of the figure cf.
  4. If the current figure is not cf, make cf the current figure and set its visibility.
  5. Get the current view angles (a, b) of the axes.
  6. Retrieve the title object of the current axes.
  7. Get the current axes handle ca.
  8. If nf is empty, create a new figure and assign it to nf. Otherwise, make nf the current figure.
  9. Set the visibility of nf to match cf.
  10. Create new axes na in the new figure and set the colormap and color limits.
  11. Copy all child objects from the current axes ca to the new axes na.
  12. Set the axis properties to be tight, equal, and turn on the grid and axis.
  13. Set the view of the new axes to match the original view angles (a, b).
  14. Enable 3D rotation for the new figure.
  15. Move the new figure window to the northeast position on the screen.
  16. Set the title of the new axes to match the original title, without interpreting special characters.
  17. 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