Plotting with different colored markers
51 ビュー (過去 30 日間)
古いコメントを表示
Hi All,
As you know, the plot command gives each line a different color so that the user can distinguish between the each dataset. When you have two lines, you have 2 colors...6 lines, 6 colors etc. Very convenient.
How can I do this but for markers instead? The number of datasets I want to plot is different each time...I might have 2,3,4,5 up to x datasets. Is there a way to represent each set using a different marker (when the number of sets is variable)?
1 件のコメント
Ali
2017 年 10 月 29 日
編集済み: Ali
2017 年 10 月 29 日
if true
--------------------------------------------------- code start
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
<</matlabcentral/answers/uploaded_files/92608/untitled.bmp>>
採用された回答
Image Analyst
2012 年 11 月 27 日
You can use scatter() and give each marker its own color if you want. You can put them on top of a line/curve plot if you want if you call "hold on" in between calls to plot() and scatter().
2 件のコメント
myetceteramail myetceteramail
2017 年 4 月 14 日
how to give each marker different colour using scatter
その他の回答 (2 件)
Nilesh Salvi
2012 年 11 月 27 日
Express the color to be assigned in plot function as RGB-Value rather than 'Short name'. To get a new color generated for every time plot function is called I assign random RGB value to the color spec. http://goo.gl/hq6q4
for i = 1:N
plot(x,y(i),[rand rand rand]);
end
that should plot N number of 'y' curves of N random shades.
参考
カテゴリ
Help Center および File Exchange で Scatter Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!