Replot a figure in another figure window without having to repeat underlying calculations

I’d like to replot a figure which is plotted as a subplot in one figure in another, separate figure on its own.
The following might give a better, simplistic idea of what I’d like to do

figure(1) ; h1 = plot(“plot some complicated plot as a part of figure(1), i.e. a subplot”) ;
figure(2) ; plot( h1 ) ; ## replot h1 in its own, full sized figure, without having to repeat all the underlying calculations that originally formed the data for plot h1

My system

  • OS: KDE Neon
  • Octave version: e.g. Version 6.1.0
  • Installation method: e.g. Manual install from source

Does “copyobj” do what you want? Try “demo copyobj”

To complement @dasergatskov answer, you could copy all the children of the original subplot axes into the new axes, e.g.:

figure (1);
hax1 = subplot (1,2,1);
hchildren = plot (hax1, rand (10));
## Alternatively retrieve axes children
## hchildren = get (hax1, "children")

figure (2)
hax2 = gca ();
copyobj (hchildren, hax2);
1 Like

The “copyobj” on its own doesn’t seem to be enough. An example of the type of chart I’m trying to reproduce is

which, as can be seen, is made up of different plotting objects such as a “pcolor” background, various “patch” objects, some “line plots” and “scatter” plots, all layered over each other via “hold on” and “hold off” commands.

Using “copyobj” as described in the other answers I can only reproduce the background.