Plotting 10 graphs with different colors and markers

59 ビュー (過去 30 日間)
Aftab Ahmed Khan
Aftab Ahmed Khan 2015 年 3 月 26 日
Hi everyone, I am plotting 10 graphs on a single figure from a different 10 sets of data. I know only these 5 colors and markers in Matlab to differentiate between them. Can you help me to get 5 more. Thank you.
colors=['-rs'; '-bo'; '-k^'; '-y+'; '-c*'];
  1 件のコメント
Ali
Ali 2017 年 10 月 29 日
if true
--------------------------------------------------- code start
This is an example for your case Aftab Ahmed
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

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

採用された回答

Star Strider
Star Strider 2015 年 3 月 26 日
編集済み: Star Strider 2015 年 3 月 26 日
Choose the colormap you want, and specify the number of levels you want.
For example:
cmap = colormap(parula(10));
then for the 7th plot, you might call plot as:
hold on
for k1 = 1:10
plot([1:10], randi(k1*5, 1, 10), 'Color',cmap(k1,:))
end
hold off
grid
You can also set the 'AxisColorOrder' and 'AxisLineStyleOrder' by default or for each axis (this example taken from another post):
set(0,'defaultaxescolororder',[0 0 0; 0.5 0.5 0.5]) %black and gray
set(0,'defaultaxeslinestyleorder',{'-*',':','o'}) %or whatever you want
In R2014b and later, replace the ‘0’ with groot.

その他の回答 (2 件)

Andrew Newell
Andrew Newell 2015 年 3 月 26 日
There is a table in LineSpec (Line Specification) with 13 different markers.

Korosh Agha Mohammad Ghasemi
Korosh Agha Mohammad Ghasemi 2020 年 12 月 7 日
編集済み: Korosh Agha Mohammad Ghasemi 2020 年 12 月 7 日
%https://zil.ink/korosh -------- Ways to contact me ----------
% Korosh Agha Mohammad Ghasemi !
% Chemical Engineering at Shiraz University
x=linspace(0,2,100);
figure;
for a=[0.1 0.5 1 2 4]
y=x.^a; %The function is hypothetical
if a == 0.1 %Any color can be substituted
y=x.^a;
plot(x,y,'k') %Now choose the color
hold on
elseif a == 0.5
y=x.^a;
plot(x,y,'b') %Now choose the color
hold on
elseif a==1
y=x.^a;
plot(x,y,'g') %Now choose the color
hold on
elseif a==2
y=x.^a;
plot(x,y,'r') %Now choose the color
hold on
elseif a==4
y=x.^a;
plot(x,y,'y') %Now choose the color
hold on
grid on
end
end

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by