
plotting in different colors with different linestyles or markers
27 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Ali
le 29 Oct 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

Réponses (3)
emami.m
le 14 Jan 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{:};
0 commentaires
Azzi Abdelmalek
le 7 Juin 2013
3 commentaires
Azzi Abdelmalek
le 7 Juin 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
le 7 Juin 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?
Edmund Watson
le 26 Oct 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
0 commentaires
Voir également
Catégories
En savoir plus sur Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!