How to combine group of plots into one with separate marker

i use this code to cobine tow figures but i want help to make loop to combine more than tow figures
thnx
fh1 = open('f1.fig');
fh2 = open('f2.fig');
ax1 = get(fh1, 'Children');
ax2 = get(fh2, 'Children');
ax2p = get(ax2(1),'Children');
copyobj(ax2p, ax1(1));

2 Commenti

Do you have the source data and scripts used to create the figure files? If you can plot a new figure using data set 1, then use the "hold on" command, and call plot again with data set 2. Call "hold off" when all data is added to one figure.
The plot function accepts a third parameter which specifies line type and marker, per this snippet from the documentation:
Various line types, plot symbols and colors may be obtained with
PLOT(X,Y,S) where S is a character string made from one element
from any or all the following 3 columns:
b blue . point - solid
g green o circle : dotted
r red x x-mark -. dashdot
c cyan + plus -- dashed
m magenta * star (none) no line
y yellow s square
k black d diamond
w white v triangle (down)
^ triangle (up)
< triangle (left)
> triangle (right)
p pentagram
h hexagram
For example, PLOT(X,Y,'c+:') plots a cyan dotted line with a plus
at each data point; PLOT(X,Y,'bd') plots blue diamond at each data
point but does not draw any line.
i don't have the source data thats why i used this method

Accedi per commentare.

Risposte (1)

Assuming that each figure only has 1 axes and you want the first axes to be the one you want to copy into
fig(1) = open('f1.fig');
fig(2) = open('f2.fig');
fig(3) = open('f3.fig');
% ...
ax = findobj(fig(1),"Type","Axes");
% identify the axes of the first figure
for i = 2:numel(fig)
PlotObjs = findobj(fig(i),"Type","Line","-or","Type","Scatter")
copyobj(PlotObjs,ax)
end
If you want to re-do the markers, identify all the plot objects and re-set their linespec/colors.
PlotObjs = findobj(fig(1),"Type","Line","-or","Type","Scatter")
for i = 1:numel(PlotObjs)
set(PlotObjs(i),"LineStyle",...)
set(PlotObjs(i),"Marker",...)
set(PlotObjs(i),"Color",...)
% etc
end
You can pre-generate the combinations of linestyle, markers, etc ahead of time and save into arrays to index in the loop

Richiesto:

il 7 Ott 2022

Risposto:

il 9 Ott 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by