フィルターのクリア

plotting in different colors with different linestyles or markers

145 ビュー (過去 30 日間)
mohsen
mohsen 2013 年 6 月 7 日
回答済み: emami.m 2021 年 1 月 14 日
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
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

サインインしてコメントする。

回答 (3 件)

emami.m
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{:};

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 6 月 7 日
  3 件のコメント
Azzi Abdelmalek
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
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
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

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by