How to combine group of plots into one with separate marker
조회 수: 2 (최근 30일)
이전 댓글 표시
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
Benjamin Thompson
2022년 10월 7일
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.
답변 (1개)
J. Alex Lee
2022년 10월 9일
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!