Plotting with different colored markers

63 次查看(过去 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
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
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.

类别

Help CenterFile Exchange 中查找有关 Scatter Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by