I create a figure containing 4 subplots like:
y = [2 2 3; 2 5 6; 2 8 9; 2 11 12];
fig = figure
for i = 1 : 4
h(i) = subplot(1,4,i)
bar(y)
end
Now I would like to exchange the order of the subplots. For example the first subplot should go in the last column (4th) and the 2nd subplot should exchange with the 3rd.
Is it doable without generating again the figure?
Perhaps you could change their 'position'
of the axes h
. For instance:
% get position
pos = get(h,'position');
% change position, 1st <-> 4th, 2nd <->3rd.
set(h(1),'position',pos{4});
set(h(4),'position',pos{1});
set(h(2),'position',pos{3});
set(h(3),'position',pos{2});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With