Plotting 10 graphs with different colors and markers
53 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Aftab Ahmed Khan
am 26 Mär. 2015
Bearbeitet: Korosh Agha Mohammad Ghasemi
am 7 Dez. 2020
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 Kommentar
Ali
am 29 Okt. 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
Akzeptierte Antwort
Star Strider
am 26 Mär. 2015
Bearbeitet: Star Strider
am 26 Mär. 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 Kommentare
Weitere Antworten (2)
Korosh Agha Mohammad Ghasemi
am 7 Dez. 2020
Bearbeitet: Korosh Agha Mohammad Ghasemi
am 7 Dez. 2020
%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
0 Kommentare
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!