Change the color of data in legend??

1 回表示 (過去 30 日間)
Big Meech
Big Meech 2014 年 5 月 6 日
コメント済み: A Jenkins 2014 年 5 月 6 日
theta2 = theta2*360/(2*pi);
theta3 = theta3*360/(2*pi);
subplot(2,2,1)
plot(index,theta1,'b.-',index,theta2,'k.-',index,theta3,'r.-')
title('Voltage Angle vs. Iteration') % title
axis([0 25 -10 30])
xlabel('iteration(s)')
ylabel('Voltage Angle (degrees)')
legend('V2 Angle','V1 Angle', 'V3 Angle')
My code is above for me ploting. I have tried multiple ways to color code the legend to the same values as my line. I have tried different ways but to no success. This is the final thing I need to for my project. It seems simple, I'm not sure what I'm missing.
Thanks in advance.

回答 (1 件)

A Jenkins
A Jenkins 2014 年 5 月 6 日
Put your labels in the same order as the data you want it to match.
legend('V1 Angle','V2 Angle','V3 Angle')
  2 件のコメント
Big Meech
Big Meech 2014 年 5 月 6 日
That's still not making a difference for me. I'm not sure what is wrong here.
A Jenkins
A Jenkins 2014 年 5 月 6 日
Perhaps your error is in a part of your code you haven't posted? What happens when you run this?
index=1:10;
theta1=1:10;
theta2=theta1*2;
theta3=theta1*3;
plot(index,theta1,'b.-',index,theta2,'k.-',index,theta3,'r.-')
legend('V1 Angle','V2 Angle','V3 Angle')

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

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by