Plotting 10 graphs with different colors and markers

조회 수: 58 (최근 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 CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by