How to mark different values with different colors and markers
조회 수: 16 (최근 30일)
이전 댓글 표시
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
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
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
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
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.
댓글 수: 0
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Phased Array Design and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!