How to mark different values with different colors and markers

16 ビュー (過去 30 日間)
Learner
Learner 2014 年 5 月 11 日
Hi,
I have a complex data values:
Z = X+iY =
0.1 0.2
-75.7 1.1
-1.0 4.1
-2.0 4.3
-1.7 5.6
-0.9 7.3
0.0 7.3
0.7 5.1
1.2 0.0
-1.3 9.0
-0.9 5.1
0.0 0.2
0.0 0.0
The first column is values of X axis (real) and second column value is Y axis (imaginary)
What I want to do is: Plot all 13 points with different color and marker and marksize.
-----------------------------
I tried this approach:
plot(Z(1,:),'g+','MarkerSize',10, Z(2,:),'c^','MarkerSize',8, .....)
-----------------------------
^^ But this approach is not working!!
Please help me out.
Thanks in advance.
  1 件のコメント
Ali
Ali 2017 年 10 月 29 日
if true
--------------------------------------------------- code start
This is an example for your case
Input is "Input_Data", two dimension matrix
Marker_Counter=1;
figure6=figure;
Markers = {'+','o','*','x','v','d','^','s','>','<'};
for i=1:10:size(Input_Data,1)
TPR=Input_Data(i:i+9,7);
FPR=Input_Data(i:i+9,8);
plot(FPR,TPR,strcat('-',Markers{Marker_Counter}));
Marker_Counter=Marker_Counter+1;
hold on
end
plot([0.5 1],[0.5 1],'--');
legend('Minpts = 100','Minpts = 200','Minpts = 300','Minpts = 400','Minpts = 500','Minpts = 600','Minpts = 700','Minpts = 800','Minpts = 900','Minpts = 1000','','Location','SouthEast');
xlabel('FPR or (1-Specificity)','FontSize',12,'FontWeight','bold'); ylabel('TPR or Spensitivity)','FontSize',12,'FontWeight','bold');
title('ROC Space');
close(gcf);
-------------------------------------------- code end
end
--------------------------------------- picture link preview

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

採用された回答

dpb
dpb 2014 年 5 月 11 日
plot creates a line object and the above are all global properties of the line.
To put them on as differently you'd have to place each point with scatter which is what it seems you're looking for, anyway.
doc scatter
for more details; reply herein if that doesn't solve the problem.
  2 件のコメント
Learner
Learner 2014 年 5 月 11 日
編集済み: Learner 2014 年 5 月 11 日
It is working.. Thanks..
Can you please tell me how to display each coordinates text (max till 2 decimal) over each point in the graph.
I tried this for first point:
scatter(Z_real(1,:), Z_imag(1,:), 100, 'r', 'x')
text(Z_real(1,:),Z_imag(1,:),num2str(Z_real(1,:),Z_imag(1,:)))
But it is not showing good results.
Means I want name above the point in the form of real and imaginary (like x+iy) form.
Thanks in advance.
Image Analyst
Image Analyst 2014 年 5 月 11 日
That's because all your markers are 'r', which is red, not the different colors like you want. Pass in an N by 3 array instead, like jet(size(Z_real, 1)).

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

その他の回答 (2 件)

dpb
dpb 2014 年 5 月 11 日
Basics are as follows--
fmt=['%.2f + %.2fi']; % build a format string for complex
scatter(Z(:,1),Z(:,2)) % plot the points
text(Z(:,1),Z(:,2),num2str(Z,fmt)) % label them per the formatting
Salt to suit; your values overlap enough may need to do some selective placement or orientation to be able to read 'em all.

Korosh Agha Mohammad Ghasemi
Korosh Agha Mohammad Ghasemi 2020 年 12 月 7 日
%https://zil.ink/korosh -------- Ways to contact me ----------
% Korosh Agha Mohammad Ghasemi !
% Chemical Engineering at Shiraz University
x=linspace(0,2,100);
figure;
for a=[0.1 0.5 1 2 4]
y=x.^a; %The function is hypothetical
if a == 0.1 %Any color can be substituted
y=x.^a;
plot(x,y,'k') %Now choose the color
hold on
elseif a == 0.5
y=x.^a;
plot(x,y,'b') %Now choose the color
hold on
elseif a==1
y=x.^a;
plot(x,y,'g') %Now choose the color
hold on
elseif a==2
y=x.^a;
plot(x,y,'r') %Now choose the color
hold on
elseif a==4
y=x.^a;
plot(x,y,'y') %Now choose the color
hold on
grid on
end
end

カテゴリ

Help Center および File ExchangePhased Array Design and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by