更改线的颜色组合图表
问题描述:
,当我将两个图形/图到一个这样的:更改线的颜色组合图表
fig1 = open('fig1.fig')
fig2 = open('fig2.fig')
ax1 = get(fig1, 'Children');
ax2 = get(fig2, 'Children');
for i = 1 : numel(ax2)
ax2Name = get(ax2(i), 'Children');
copyobj(ax2Name, ax1(i));
end
是否有可能修改(其他城市)中存在的fig2线的颜色?情节有不同颜色的3条线。
答
x = 1:0.1:5;
y1 = x.^2;
y2 = sqrt(x);
y3 = sin(x);
figure;
plot(x, y1, x, y2);
fig1 = gcf;
ax1 = fig1.Children; % same as get(fig1, 'Children')
line1 = ax1.Children;
figure;
plot(x, y3);
fig2 = gcf;
ax2 = fig2.Children
for l = line1 % iterate over Line array
copyobj(l, ax2) % copy each Line object from ax1 to ax2
end
disp(ax2.Children)
line2 = ax2.Children;
line2(1).Color = [1 0 0]; % first line (^2): red
line2(2).Color = [0 1 0]; % second line (sqrt): green
line2(3).Color = [0 0 1]; % third line (sine): blue
如果一个情节有3行不同的颜色,是否有可能只改变一个特定的行? –
我不知道如何订购。除此之外,'c(1)':第一行,'c(2)':第二行,'c(3)':第三行。 'set(c(3),'Color',[0 1 0])'将第三个设置为绿色。 – Jeon
我有点不确定如何将这与我在帖子中提供的示例结合起来。有可能适合我的例子吗? –