views:

62

answers:

0

I'm trying to plot out readings from a device I'm testing, I only need one legend per figure, and there are 3 graphs per figure.

I'm giving the first graph a legend with the 'BestOutside' flag. Unfortunately, when i plot the other two graphs they don't line up with the first graph, and partially hide the legend.

How do I make sure the second two plots have the same dimensions of the first one, such that the legend stays on the side, and the plots all line up nicely?

Here's the relevant code I'm working with, I am not the original author.

scatterPlot = figure('Name', figureTitle, 'Position',...
    [monitorPos(1,3)/2 0 monitorPos(1,3)/2 monitorPos(1,4)])

for axis = 1:3
subplot(3,1,axis)
hold on    

for intervalInd = 1 : numberOfIntervals
    intervalStart = (intervalInd -1)*intervalLength + 1;
    intervalEnd = min(intervalStart + intervalLength, plotLen);        

    intervalHandle(intervalInd) = scatter(...
       x(intervalStart:GRAPHING_RATIO:intervalEnd),...
       y(intervalStart:GRAPHING_RATIO:intervalEnd, axis),...
       MARKER_SIZE,intervalColor(intervalInd, :), 'filled');               

end

if axis == 1
    % Only add legend and full title to top-most graph. 
    legend(intervalHandle, legendStr, 'Location', 'BestOutside')
    titleStr={figureTitle;Constants.AXES_LABEL{axis}};
else
    titleStr = Constants.AXES_LABEL(axis);
end
title(titleStr);

xlabel(Constants.OBFUSCATED_NAME);
ylabel('Lorem Ipsum');
minValue = min(y(:,axis));
ylim([minValue minValue+ySpan]);

end

related questions