How to get different color with respect to an figure.

3 次查看(过去 30 天)
I have two figures first one with different colors and second one with one color.
Could anyone help me how to get the second figure with different color with respect to first figure.
code:
first figure
plot(PPP(:,1),PPP(:,2),'k*')
hold on
for cc=1:centroids
plot(PPP(c(:,a)==cc,1),PPP(c(:,a)==cc,2),'o','color',cluster_colors{cc});
end
second figure
figure
plot(1:N_UE,A,'-k*')
could anyone please help me on this.
  4 个评论
jaah navi
jaah navi 2019-3-1
the color of second figure should be the same with repect to first figure.
But with respect to the command used for plotting the second figure gives only one color.
Could you please help me to get the second figure with colors similar to first figure.
Walter Roberson
Walter Roberson 2019-3-1
Of course the second figure only gives one color: you only plot one line and you tell it that the line should be black ('k') with a simple solid line ('-') with asterisk marker ('*')
It is not possible to have multiple colors in a single line() object.
It is possible to create a single line() object and to scatter() markers on top of it, but it is not clear that is what you want.

请先登录,再进行评论。

采纳的回答

KSSV
KSSV 2019-3-1
YOu should use the predefined colors to do that.
color = rand(6,3) ;
x = 1:6 ;
y = rand(size(x)) ;
figure(1)
hold on
for i = 1:6
plot(x(i),y(i),'*','MarkerEdgeColor',color(i,:)) ;
end
figure(2)
hold on
for i = 1:6
plot(x(i),y(i),'*','MarkerEdgeColor',color(i,:)) ;
end
plot(x,y,'b')

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Identification 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by