Plotting with different colored markers

51 ビュー (過去 30 日間)
Rainer
Rainer 2012 年 11 月 27 日
編集済み: Ali 2017 年 10 月 29 日
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
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
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
myetceteramail myetceteramail 2017 年 4 月 14 日
how to give each marker different colour using scatter
Image Analyst
Image Analyst 2017 年 4 月 14 日
One of the inputs to scatter is a list of colors for each marker.

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

その他の回答 (2 件)

Matt Fig
Matt Fig 2012 年 11 月 27 日
編集済み: Matt Fig 2012 年 11 月 27 日
You can set the linestyleorder.
clf
set(gca,'linestyleorder',{'-',':','-.','--'},...
'colororder',[0 0 1;0 .5 0;1 0 0],...
'nextplot','add')
x = 0:.01:1;
plot(x,bsxfun(@power,x.',1:12))

Nilesh Salvi
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.
  1 件のコメント
Rainer
Rainer 2012 年 11 月 27 日
Good idea too.

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

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by