plot multipe figures with diferents color

i have matlab code that generate peaks , so i want to plot each peaks with different color
my last code for generat all peaks are
figure(i),plot3(mx,my,mz,'r*');
and this one plot all peaks but with same color witch are red

回答 (2 件)

Mahdi
Mahdi 2014 年 5 月 28 日

0 投票

You can iterate through each point with a for loop
ColoursToUse=['r' 'b' 'g' 'c']
figure(1)
hold on
for i=1:4
plot3(mx(i), my(i), mz(i), strcat(ColoursToUse(i),'o'))
end
Then this will show the first four peaks for example in red, blue, green, and cyan.

3 件のコメント

Malstheet
Malstheet 2014 年 5 月 28 日
yaeh but these peaks are for expl a multi point on 3d
Malstheet
Malstheet 2014 年 5 月 28 日
didnt work for me
Mahdi
Mahdi 2014 年 5 月 30 日
If I understood it properly from below, you can do a similar thing to what I did. Let's say you have 4 figures (in your example, figure(i) has i ranging from 1 to 4)
ColoursToUse=['r' 'b' 'g' 'c']
Then inside your loop
figure(i),plot3(mx,my,mz,strcat(ColoursToUse(i),'*'));

サインインしてコメントする。

Malstheet
Malstheet 2014 年 5 月 28 日

0 投票

i want to display each figure with diffirent colors

タグ

質問済み:

2014 年 5 月 28 日

コメント済み:

2014 年 5 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by