Filter löschen
Filter löschen

How to get different color with respect to an figure.

3 Ansichten (letzte 30 Tage)
jaah navi
jaah navi am 1 Mär. 2019
Kommentiert: Walter Roberson am 1 Mär. 2019
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 Kommentare
jaah navi
jaah navi am 1 Mär. 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 am 1 Mär. 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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

KSSV
KSSV am 1 Mär. 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')

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Object Identification finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by