Effacer les filtres
Effacer les filtres

How to get different color with respect to an figure.

3 vues (au cours des 30 derniers jours)
jaah navi
jaah navi le 1 Mar 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 commentaires
jaah navi
jaah navi le 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 le 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.

Connectez-vous pour commenter.

Réponse acceptée

KSSV
KSSV le 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')

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Object Identification dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by