In matlab it is difficult to put two legends in one figure. However, there are several tricks to get this done. One of them is as follows,
% Plot with 9 curves
ph=plot(rand(20,9));
set(gca,'ylim',[-2,5]);
% Label curves 1 and 5
legend(ph(1),'trace one');
% Add and invisible axes
ah=axes('position',get(gca,'position'),'visible','off');
% Add new legend
legend(ah,ph(5),'trace five','location','west');
Cycle through markers in plot loop
If you are plotting in a loop, and want each loop to use a different plot
marker, then
% Define the markers
markers = '.ox+*sdv^<>ph
% The dataset
y=rand(10);
x=[1:10];
% The Loop for plots
for i=1:10,
% Select marker if there are more data than the markers
marker=markers(rem(i,length(markers))+1)
% Plot
plot(x,y(:,i),marker)
hold on
end
No comments:
Post a Comment