Borrar filtros
Borrar filtros

Plotting with different colored markers

63 visualizaciones (últimos 30 días)
Rainer
Rainer el 27 de Nov. de 2012
Editada: Ali el 29 de Oct. de 2017
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 comentario
Ali
Ali el 29 de Oct. de 2017
Editada: Ali el 29 de Oct. de 2017
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>>

Iniciar sesión para comentar.

Respuesta aceptada

Image Analyst
Image Analyst el 27 de Nov. de 2012
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 comentarios
myetceteramail myetceteramail
myetceteramail myetceteramail el 14 de Abr. de 2017
how to give each marker different colour using scatter
Image Analyst
Image Analyst el 14 de Abr. de 2017
One of the inputs to scatter is a list of colors for each marker.

Iniciar sesión para comentar.

Más respuestas (2)

Matt Fig
Matt Fig el 27 de Nov. de 2012
Editada: Matt Fig el 27 de Nov. de 2012
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 el 27 de Nov. de 2012
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.

Categorías

Más información sobre Scatter Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by