Clear Filters
Clear Filters

How to get different color with respect to an figure.

3 views (last 30 days)
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 Comments
jaah navi
jaah navi on 1 Mar 2019
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 on 1 Mar 2019
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.

Sign in to comment.

Accepted Answer

KSSV
KSSV on 1 Mar 2019
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')

More Answers (0)

Categories

Find more on Graphics Object Identification in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!