How to mark different values with different colors and markers

조회 수: 13 (최근 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 CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by