From: John on
Hello!

I posted earlier about getting multiple legends. I cleaned up my code a little bit, and am starting to understand my error (but still haven't solved my problem). Again, my issue is trying to generate multiple legends for the same plot in a GUI. I collected data during a test from multiple data channels over a series of runs. For my current problem, I'm trying to plot channels 1, 2, and 3 for runs 1 and 2. I can plot the data and generate a single legend for Run1, but I can't generate a separate legend for Run2.

Here is the "cleaned-up" code:

% RunNumberPlottedList = The Runs from the test being plotted
% Channels2Analyze_Contents = The Channels of data being plotted that were collected for
each Run of the test
% xData = data used for x axis
% yData = data used for y axis
% data_axes = the tage for the plot in my GUI

for i = 1:length(RunNumberPlottedList);
if i == 1
plot(handles.data_axes,xData,yDataMatrix) % plots entire data set
ax1 = gca;
eval(['legend_handle' num2str(i) '= legend(Channel2Analyze_Contents)']);
set(get(eval(['legend_handle' num2str(i)]),'title'),'string',...
RunNumberPlottedList(i),'fontweight','bold')
elseif i>1
eval(['ax' num2str(i) '= axes(''Position'',...
get(ax1,''Position''),''Visible'',''off'',''Color'',''none'')']);
eval(['legend_handle' num2str(i) '= legend(Channel2Analyze_Contents)']);
set(get(eval(['legend_handle' num2str(i)]),'title'),'string',...
RunNumberPlottedList(i),'fontweight','bold')
end
end

This code does not work properly. My problem is that I'm not plotting to the new axes "ax2". This leaves ax2 "empty" and trying to generate a legend for an empty plot appears impossible. I'm wary to plot to multiple axes because this will complicate the coloring of the lines as each new plot will re-start the ColorOrder. Please Help!!!
From: Andy on
Please don't duplicate your post. Just reply to your existing thread if you have new code to look at.
 | 
Pages: 1
Prev: 921600 baud rate
Next: magnitude shift (ifft)