I'm trying to add a legend to my graph in Matlab.
Each colour should have a different legend, i.e., red 'r' should say upregulated, blue 'b' downregulated and green 'g' unregulated.
I've tried putting the code directly after setting the colour but this doesn't work well.
Any ideas?
function functionForNumber5(M)
fig = figure;
ax = axes('nextplot','add','xlim',[1,5],'ylim',[0,2],'xtick',
[1:.5:5],'ytick',[0:.5:2]);
xlabel('Time (Hours)');
ylabel('Expression Level');
for it1 = 1 : 24
if M(5,it1) > 1.3
currentColor = 'r';
elseif M(5,it1) < 0.7
currentColor = 'b';
else
currentColor = 'g';
end
plot(ax,[1:5],M(:,it1),'color',currentColor);
end
I really need a colour key to represent whether my plots are upregulated, downregulated or nonregulated, that is, 3 keys on the legend only.