![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/186496/image.bmp)
plotting in different colors with different linestyles or markers
73 次查看(过去 30 天)
显示 更早的评论
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 个评论
Ali
2017-10-29
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/186496/image.bmp)
回答(3 个)
emami.m
2021-1-14
% 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 个评论
Azzi Abdelmalek
2013-6-7
3 个评论
Azzi Abdelmalek
2013-6-7
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
2013-6-7
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
2017-10-26
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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!