MATLAB Answers

Plotting 10 graphs with different colors and markers

516 views (last 30 days)
Aftab Ahmed Khan
Aftab Ahmed Khan on 26 Mar 2015
Commented: Ali on 29 Oct 2017
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 Comment

Ali
Ali on 29 Oct 2017
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

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 26 Mar 2015
Edited: Star Strider on 26 Mar 2015
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.

  0 Comments

Sign in to comment.

More Answers (1)

Tags