plotting in different colors with different linestyles or markers

96 visualizaciones (últimos 30 días)
mohsen
mohsen el 7 de Jun. de 2013
Respondida: emami.m el 14 de En. de 2021
I want to plot a multiple graf of varing a function in one plot with different color with different markers or different linestyle. I searched for it since 2 weeks ago. I found some method but they didn't help my request.
% mmm=['r';'b';'k';'m';'g'];
mmm=[1 0 0; 0 1 0;0 0 1;0 0 0;1 0 1];
kkk={':','--','-.','-','--'};
% set(gca(),'LineStyleOrder',kkk,'ColorOrder','default','NextPlot','replacechildren')
set(gca,'ColorOrder',mmm);
set(gca,'LineStyleOrder',kkk);
1- If i write the first line instead of 2nd, matlab can not plot with different colors, why?
2- At the 3rd line I define linestye, but matlab plots just with style of ':',why?(with commands in line 5 & 6)
Thanks.
  1 comentario
Ali
Ali el 29 de Oct. de 2017
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

Iniciar sesión para comentar.

Respuestas (3)

emami.m
emami.m el 14 de En. de 2021
% Try this code. You can use it for all other line properties
h = plot(1:10,1:10,1:10,5:14,1:10,3:12,1:10,7:16); % Sample plot
kkk = {'+' ; 'o' ; '*' ; 'd'};
[h(:).Marker] = kkk{:};

Azzi Abdelmalek
Azzi Abdelmalek el 7 de Jun. de 2013
  3 comentarios
Azzi Abdelmalek
Azzi Abdelmalek el 7 de Jun. de 2013
mohsen commented
there is another notation:
with command of hold all
the colour will be change automatically but variation of marker and line is dificult
Azzi Abdelmalek
Azzi Abdelmalek el 7 de Jun. de 2013
mohsen commented
if I use just this command:
set(gca(),'LineStyleOrder',kkk,'ColorOrder',[0 0 0],'NextPlot','replacechildren')
each figure has different marker or line but with black color
it means that i can't plot with different color
is there any one help me?

Iniciar sesión para comentar.


Edmund Watson
Edmund Watson el 26 de Oct. de 2017
I gave up in the end. I decided it was better just to do something like this
sizey = size(ydata);
style= {'-k','--b',':y'};
hold on
for k= 1:sizey(1)
plot(xdata,xten(k,:),style{k})
end

Categorías

Más información sobre Graphics Object Programming 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