How can I add an additional overall legend for additional data overlaid on a 3x1 subplot, which already has a legend for each of the 3 plots?

I'm working on a script that creates a 3x1 subplot of a variety of data read in from text files. The final plot dynamically changes, depending on what data is read in from the file. Once each of them has been plotted, I need to overlay each of the plots with symbols denoting different actions taken over the course of the plot. These actions will need a legend associated with them. However, only 1 legend is necessary because they are all the same symbols. Each of the subplots has its own legend as well, corresponding with data from each of the subplots. I'm wondering if it's possible to have a fourth legend on this plot for the symbols that are overlaid on the 3 plots. When these symbols are overlaid on the plots, there are 8 possible symbols. Not all have to be used and it is not known before which will be used. I was thinking I could have a hard coded legend for all 8 possible symbols placed on the side of the subplot, and then all are noted even if they're not all used. Any ideas on how to go about this would be appreciated. Thank you. I don't know that it's helpful to add the code I'm working on here, as its very long, but I would be happy to share it if it would help.

4 Comments

The one thought that comes to mind is to overlay another axes that bounds the subplot region axes and add the "super-legend" to it. Finding a piece of ground to place it on might be a problem.
I'd think you could take the essence of the appearance you're trying to achieve and provide a sample piece of code w/ random iputs or just straight lines and post that in--oh, I'd say 25 lines or so. (I can identify that song in ??? notes! :) ) It doesn't take all the complexity of the full thing to see the gist of the display.
I want 1 legend for the following set of data, which will appear on each graph: nodA, nodB, nodX, dither, LOS, ta_pos_goto, coord_init, and coord_correct. I was thinking that the legend could even appear in another figure window in case it takes up too much space in the figure with the 3x1 subplot. Otherwise, I could put it off to a side or down below in the same figure window as the original subplot. Here's the code for plotting the data sets.
%%Create a 3x1 stripchart of the 3 plots described above.
figure(1)
subplot(3,1,1)
%Plot 1 data obtained from the gyroscopic drift data.
plot1=plot(times,ta_tsc_tsc_mcs_hk_atc_gyro_drift_el,'b', times,ta_tsc_tsc_mcs_hk_atc_gyro_drift_xel,'g',times,ta_tsc_tsc_mcs_hk_atc_gyro_drift_los, 'r');
grid on
legend1=legend(plot1, legendArray1,'Location','Best');
set(legend1, 'FontSize',10);
datetick('x','HH:MM:SS', 'keeplimits')
title(['TA Gyroscopic Drift' UTtimeCharArray(1,12:19) ' --> ' UTtimeCharArray(end,12:19) ' UT '],'FontSize',10)
xlim([min(times), max(times)])
xlabel('Time (UT)');
ylabel('Drift (arcsec/sec)');
hold on
%%Added Command Marker Code from Scott Miller's hk_monitor_plot_03_5
% This code marks the plots at the times of the specified command strings
% passed as an argument to function 'log_parsing'. This code may be
% commented out and the usual hk_monitor_plot should run without issue.
start_time = times(1);
end_time = times(length(times));
% User selects the log file directory. The log file for Gr_F111 is under
% the following path: /Users/sofiauser/GreatCommisioningFlights/2013-07-12_GR_F111/logs/cmdlogs
if ~exist('LogDir','var')
display('choose Log File directory')
LogDir = uigetdir('~/GreatCommisioningFlights','choose Log File directory')
end
cd(LogDir)
% if logfile directory is not properly selected above, if you navigate to a
% different directory and select the log file it will not open properly
if ~exist('logname','var')
logname = uigetfile('~/*.txt','select log file to identify and plot commands')
end
[log_file] = command_log_read_in(logname);
% Command structures definition
% Note: modify the 'plot_yaxis' field to make it work on the plot; e.g.,
% some variation on the y-axis limits captured in the plot_y_axis variable
plot_y_axis = ylim;
commands = command_marker_definitions(plot_y_axis);
% Select which commands you would like to overlay on the centroid plot by
% choosing 'true', otherwise put 'false'
commands.nodA.toggle = true;
commands.nodB.toggle = true;
commands.nodX.toggle = true;
commands.dither.toggle = true;
commands.LOS.toggle = true;
commands.ta_pos_goto.toggle = true;
commands.coord_init.toggle = true;
commands.coord_correct.toggle = true;
% This checks if the user-selected toggle is true and then plots the
% appropriate command times on the figure
if commands.nodA.toggle == true;
[plot1, commands.nodA] = command_marker_plot_v2(log_file,commands.nodA,'Command Log',start_time,end_time,plot1);
end
if commands.nodB.toggle == true;
[plot1, commands.nodB] = command_marker_plot_v2(log_file,commands.nodB,'Command Log',start_time,end_time,plot1);
end
if commands.nodX.toggle == true;
[plot1, commands.nodX] = command_marker_plot_v2(log_file,commands.nodX,'Command Log',start_time,end_time,plot1);
end
if commands.dither.toggle == true;
[plot1, commands.dither] = command_marker_plot_v2(log_file,commands.dither,'Command Log',start_time,end_time,plot1);
end
if commands.LOS.toggle == true;
[plot1, commands.LOS] = command_marker_plot_v2(log_file,commands.LOS,'Command Log',start_time,end_time,plot1);
end
if commands.ta_pos_goto.toggle == true;
[plot1, commands.ta_pos_goto] = command_marker_plot_v2(log_file,commands.ta_pos_goto,'Command Log',start_time,end_time,plot1);
end
if commands.coord_init.toggle == true;
[plot1, commands.coord_init] = command_marker_plot_v2(log_file,commands.coord_init,'Command Log',start_time,end_time,plot1);
end
if commands.coord_correct.toggle == true;
[plot1, commands.coord_correct.toggle] = command_marker_plot_v2(log_file,commands.coord_correct,'Command Log',start_time,end_time,plot1);
end
subplot(3,1,2)
plot2=plot(times,ta_trc_trc_tracking_table_cent_ref_track_aoi,'b', times,ta_trc_trc_tracking_table_cent_ref_track_camera,'g',times,ta_trc_trc_rof_table_ref_rof1_aoi, 'r', times, ta_trc_trc_rof_table_ref_rof2_aoi,'k');
grid on
legend2=legend(plot2, legendArray2,'Location','Best', 'Interpreter', 'none');
set(legend2, 'FontSize',10);
datetick('x','HH:MM:SS', 'keeplimits')
title(['TA Tracking Subsystem' UTtimeCharArray(1,12:19) ' --> ' UTtimeCharArray(end,12:19) ' UT '],'FontSize',10)
xlim([min(times), max(times)])
ylim([min(ta_trc_trc_tracking_table_cent_ref_track_aoi), max(ta_trc_trc_tracking_table_cent_ref_track_aoi)+1])
xlabel('Time (UT)');
ylabel('Value');
hold on
% This checks if the user-selected toggle is true and then plots the
% appropriate command times on the figure
plot_y_axis = ylim;
commands = command_marker_definitions(plot_y_axis);
% Select which commands you would like to overlay on the centroid plot by
% choosing 'true', otherwise put 'false'
commands.nodA.toggle = true;
commands.nodB.toggle = true;
commands.nodX.toggle = true;
commands.dither.toggle = true;
commands.LOS.toggle = true;
commands.ta_pos_goto.toggle = true;
commands.coord_init.toggle = true;
commands.coord_correct.toggle = true;
if commands.nodA.toggle == true;
[plot2, commands.nodA] = command_marker_plot_v2(log_file,commands.nodA,'Command Log',start_time,end_time,plot2);
end
if commands.nodB.toggle == true;
[plot2, commands.nodB] = command_marker_plot_v2(log_file,commands.nodB,'Command Log',start_time,end_time,plot2);
end
if commands.nodX.toggle == true;
[plot2, commands.nodX] = command_marker_plot_v2(log_file,commands.nodX,'Command Log',start_time,end_time,plot2);
end
if commands.dither.toggle == true;
[plot2, commands.dither] = command_marker_plot_v2(log_file,commands.dither,'Command Log',start_time,end_time,plot2);
end
if commands.LOS.toggle == true;
[plot2, commands.LOS] = command_marker_plot_v2(log_file,commands.LOS,'Command Log',start_time,end_time,plot2);
end
if commands.ta_pos_goto.toggle == true;
[plot2, commands.ta_pos_goto] = command_marker_plot_v2(log_file,commands.ta_pos_goto,'Command Log',start_time,end_time,plot2);
end
if commands.coord_init.toggle == true;
[plot2, commands.coord_init] = command_marker_plot_v2(log_file,commands.coord_init,'Command Log',start_time,end_time,plot2);
end
%if commands.coord_correct.toggle == true;
%[plot2, commands.coord_correct.toggle] = command_marker_plot_v2(log_file,commands.coord_correct,'Command Log',start_time,end_time,plot2);
%end
subplot(3,1,3)
%%ADDITION TO FINAL PLOT
%Plot of 3 consistent elements
hplt=plot(times,coord_pos_sibs_xfpi,'m--', 'DisplayName', 'coord\_pos\_sibs\_xfpi');
hold on
hplt=plot(times,coord_pos_sibs_yfpi,'m', 'DisplayName', 'coord\_pos\_sibs\_yfpi');
hold on
hplt=plot(times,coord_pos_fpi_fov_vpa, 'k', 'DisplayName', 'coord\_pos\_fpi\_fov\_vpa');
hold on
hleg=legend('-DynamicLegend');
set(hleg, 'FontSize',10);
grid on
datetick('x','HH:MM:SS', 'keeplimits')
title(['Position of SIBS on FPI' UTtimeCharArray(1,12:19) ' --> ' UTtimeCharArray(end,12:19) ' UT '],'FontSize',10)
xlim([min(times), max(times)])
xlabel('Time (UT)');
ylabel('Value');
hold on
%Add AOI's to the plot:
%Find a unique list of all AOI's that were tracked on during the course of the observation. Remove 0 from the list.
AOI_unique=unique(C2);
while isequal(AOI_unique(1), 0)
AOI_unique(1)=[];
end
%Associate each of the unique AOIs with a color, recycling through the
%colors when they have all been used.
colors={'r' 'g' 'b' 'c' };
colors_dashed={'r--' 'g--' 'b--' 'c--'};
%for each of those unique AOI's, plot the row vs. time and column vs.
%time
for i=1:length(AOI_unique)
if AOI_unique(i)==1
[filename_aoi_1 pathname_aoi_1]= uigetfile('~/*_AOI_1_out_Z.txt','Select the appropriate test file under **_AOI_1_out_Z.txt');
filepath_aoi1=fullfile(pathname_aoi_1,filename_aoi_1);
[TimeHdr CameraID1 Col1 Row1 Quality1 Width1 RA1 Dec1 Error_est1] = textread(filepath_aoi1, repmat('%s ', 1,9),1);
[Timecell cam1 col1 row1 qual1 wid1 ra1 dec1 error1]=textread(filepath_aoi1, '%s %f %f %f %f %f %f %f %f ', 'headerlines', 1);
%%Plot
hplt=plot(times, col1, colors{mod(i-1,4)+1}, 'DisplayName', 'column 1');
hold on
hplt=plot(times, row1, colors_dashed{mod(i-1,4)+1}, 'DisplayName', 'row 1');
hold on
hleg=legend('-DynamicLegend');
set(hleg, 'FontSize',10);
grid on
elseif AOI_unique(i)==2
[filename_aoi_2 pathname_aoi_2]= uigetfile('~/*_AOI_2_out_Z.txt','Select the appropriate test file under **_AOI_2_out_Z.txt');
filepath_aoi2=fullfile(pathname_aoi_2,filename_aoi_2);
[TimeHdr CameraID2 Col2 Row2 Quality2 Width2 RA2 Dec2 Error_est2] = textread(filepath_aoi2, repmat('%s ', 1,9),1);
[Timecell cam2 col2 row2 qual2 wid2 ra2 dec2 error2]=textread(filepath_aoi2, '%s %f %f %f %f %f %f %f %f ', 'headerlines', 1);
%%Plot
hplt=plot(times, col2, colors{mod(i-1,4)+1}, 'DisplayName', 'column 2');
hold on
hplt=plot(times, row2, colors_dashed{mod(i-1,4)+1}, 'DisplayName', 'row 2');
hold on
hleg=legend('-DynamicLegend');
set(hleg, 'FontSize',10);
grid on
elseif AOI_unique(i)==3
[filename_aoi_3 pathname_aoi_3]= uigetfile('~/*_AOI_3_out_Z.txt','Select the appropriate test file under **_AOI_3_out_Z.txt');
filepath_aoi3=fullfile(pathname_aoi_3,filename_aoi_3);
[TimeHdr CameraID3 Col3 Row3 Quality3 Width3 RA3 Dec3 Error_est3] = textread(filepath_aoi3, repmat('%s ', 1,9),1);
[Timecell cam3 col3 row3 qual3 wid3 ra3 dec3 error3]=textread(filepath_aoi3, '%s %f %f %f %f %f %f %f %f ', 'headerlines', 1);
%%Plot
hplt=plot(times, col3, colors{mod(i-1,4)+1}, 'DisplayName', 'column 3');
hold on
hplt=plot(times, row3, colors_dashed{mod(i-1,4)+1}, 'DisplayName', 'row 3');
hold on
hleg=legend('-DynamicLegend');
grid on
% This checks if the user-selected toggle is true and then plots the
% appropriate command times on the figure
if commands.nodA.toggle == true;
[hplt, commands.nodA] = command_marker_plot_v2(log_file,commands.nodA,'Command Log',start_time,end_time,hplt);
end
if commands.nodB.toggle == true;
[hplt, commands.nodB] = command_marker_plot_v2(log_file,commands.nodB,'Command Log',start_time,end_time,hplt);
end
if commands.nodX.toggle == true;
[hplt, commands.nodX] = command_marker_plot_v2(log_file,commands.nodX,'Command Log',start_time,end_time,hplt);
end
if commands.dither.toggle == true;
[hplt, commands.dither] = command_marker_plot_v2(log_file,commands.dither,'Command Log',start_time,end_time,hplt);
end
if commands.LOS.toggle == true;
[hplt, commands.LOS] = command_marker_plot_v2(log_file,commands.LOS,'Command Log',start_time,end_time,hplt);
end
if commands.ta_pos_goto.toggle == true;
[hplt, commands.ta_pos_goto] = command_marker_plot_v2(log_file,commands.ta_pos_goto,'Command Log',start_time,end_time,hplt);
end
if commands.coord_init.toggle == true;
[hplt, commands.coord_init] = command_marker_plot_v2(log_file,commands.coord_init,'Command Log',start_time,end_time,hplt);
end
if commands.coord_correct.toggle == true;
[hplt, commands.coord_correct.toggle] = command_marker_plot_v2(log_file,commands.coord_correct,'Command Log',start_time,end_time,hplt);
end
set(legendAxListener,'Enable','on');;
%%Save the file
Any help is appreciated. Thank you!
Again, make a toy example w/ random data that runs standalone that gives the gist of what you'd like. Shouldn't take but a fraction of the above; you don't need all the fancies; just the basic idea.
Help the helper...
Ok, I hope this helps. Thank you again for looking at this. This will just be 1 plot, with data overlaid on the plot. I imagine that if I can have a "super legend" along with a legend for 1 plot, it should translate to the 3x1 stripchart. The other thing I was thinking of, and since I'm still relatively new to matlab, maybe someone could give an opinion, is on whether I should overlay the second plot on the first using the axes command? Then I could have a separate legend for that second axis and the first. Let me know if this would be a good ideas as well. Thanks.
AOI=[0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 8 8 8 8 8 8];
row1=[35 35 35 35 36 36.5 37 35 37 35 36 37 36 35 37 34 34 35 36 36 36 37 37 37 38 38 34 34 35 35 35 35 35 35 35 35 35 36 36.5 37 35 37 36 35 37 34 34 35 36 36 36 37 37 37 38 38 34 34 35 35 35 35 35];
col1= [56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47 56 56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47];
row2=[35 35 35 35 36 36.5 37 35 37 35 36 37 36 35 37 34 34 35 36 36 36 37 37 37 38 38 34 34 35 35 35 35 35 35 35 35 35 36 36.5 37 35 37 36 35 37 34 34 35 36 36 36 37 37 37 38 38 34 34 35 35 35 35 35];
col2= [56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47 56 56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47];
row3=[35 35 35 35 36 36.5 37 35 37 35 36 37 36 35 37 34 34 35 36 36 36 37 37 37 38 38 34 34 35 35 35 35 35 35 35 35 35 36 36.5 37 35 37 36 35 37 34 34 35 36 36 36 37 37 37 38 38 34 34 35 35 35 35 35];
col3= [56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47 56 56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47];
row4=[25 25 25 25 26 26.5 27 25 27 25 26 27 26 25 27 24 24 25 26 26 26 27 27 27 28 28 24 24 25 25 25 25 25 25 25 25 25 26 26.5 27 25 27 26 25 27 24 24 25 26 26 26 27 27 27 28 28 24 24 25 25 25 25 25];
col4= [56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47 56 56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47];
row5=[35 35 35 35 36 36.5 37 35 37 35 36 37 36 35 37 34 34 35 36 36 36 37 37 37 38 38 34 34 35 35 35 35 35 35 35 35 35 36 36.5 37 35 37 36 35 37 34 34 35 36 36 36 37 37 37 38 38 34 34 35 35 35 35 35];
col5= [66 67 67 68 66 67 66 66 66 67 65 65 66 66 66 64 65 65 66 66 67 67 68 68 66 66 65 66 65 66 67 66 66 67 67 68 66 67 66 66 66 67 65 65 66 66 66 64 65 65 66 66 67 67 68 68 66 66 65 66 65 66 67];
row6=[35 35 35 35 36 36.5 37 35 37 35 36 37 36 35 37 34 34 35 36 36 36 37 37 37 38 38 34 34 35 35 35 35 35 35 35 35 35 36 36.5 37 35 37 36 35 37 34 34 35 36 36 36 37 37 37 38 38 34 34 35 35 35 35 35];
col6= [56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47 56 56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47];
row7=[35 35 35 35 36 36.5 37 35 37 35 36 37 36 35 37 34 34 35 36 36 36 37 37 37 38 38 34 34 35 35 35 35 35 35 35 35 35 36 36.5 37 35 37 36 35 37 34 34 35 36 36 36 37 37 37 38 38 34 34 35 35 35 35 35];
col7= [56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47 56 56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47];
row8=[2:2:126];
col8= [56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47 56 56 57 57 58 56 57 56 56 56 57 45 45 46 46 46 44 45 45 46 46 47 47 48 48 46 46 45 46 45 46 47];
coord=[2:2:126];
times=[1:63];
AOI_unique=unique(AOI);
num_AOI=length(AOI_unique);
colors={'r' 'g' 'b' 'c' };
%while num_AOI>length(colors)
hplt=plot(times,coord, 'DisplayName', 'coord\_pos\_sibs\_xfpi');
hold on
hleg=legend('-DynamicLegend');
set(hleg, 'FontSize',10);
grid on
datetick('x','HH:MM:SS', 'keeplimits')
title(['Position of SIBS on FPI'])
xlim([min(times), max(times)])
xlabel('Time (UT)');
ylabel('Value');
hold on
for i=1:length(AOI_unique)
if AOI_unique(i)==1
%%Plot
hplt=plot(times, col1, colors{mod(i-1,4)+1}, 'DisplayName', 'column 1');
hold on
hplt=plot(times, row1, 'c--', 'DisplayName', 'row 1');
hold on
hleg=legend('-DynamicLegend');
set(hleg, 'FontSize',10);
grid on
elseif AOI_unique(i)==2
%%Plot
hplt=plot(times, col2, colors{mod(i-1,4)+1}, 'DisplayName', 'column 2');
hold on
hplt=plot(times, row2, 'g--', 'DisplayName', 'row 2');
hold on
hleg=legend('-DynamicLegend');
set(hleg, 'FontSize',10);
grid on
elseif AOI_unique(i)==3
%%Plot
hplt=plot(times, col3, colors{mod(i-1,4)+1}, 'DisplayName', 'column 3');
hold on
hplt=plot(times, row3, 'b--', 'DisplayName', 'row 3');
hold on
hleg=legend('-DynamicLegend');
grid on
elseif AOI_unique(i)==4
%%Plot
hplt=plot(times, col4, colors{mod(i-1,4)+1}, 'DisplayName', 'column 4');
hold on
hplt=plot(times, row4, 'r--', 'DisplayName', 'row 4');
hold on
hleg=legend('-DynamicLegend');
set(hleg, 'FontSize',10);
grid on
elseif AOI_unique(i)==5
%%Plot
hpltA=plot(times, col5, colors{mod(i-1,4)+1}, 'DisplayName', 'column 5');
hold on
hplt=plot(times, row5, 'c--', 'DisplayName', 'row 5');
hold on
hleg=legend('-DynamicLegend');
set(hleg, 'FontSize',10);
grid on
elseif AOI_unique(i)==6
%%Plot
hplt=plot(times, col6, colors{mod(i-1,4)+1}, 'DisplayName', 'column 6');
hold on
hpltA=plot(times, row6, 'g--', 'DisplayName', 'row 6');
hold on
hleg=legend('-DynamicLegend');
set(hleg, 'FontSize',10);
grid on
elseif AOI_unique(i)==7
%%Plot
hplt=plot(times, col7, colors{mod(i-1,4)+1}, 'DisplayName', 'column 7');
hold on
hplt=plot(times, row7, 'b--', 'DisplayName', 'row 7');
hold on
hleg=legend('-DynamicLegend');
set(hleg, 'FontSize',10);
grid on
elseif AOI_unique(i)==8
%%Plot
hplt=plot(times, col8, colors{mod(i-1,4)+1}, 'DisplayName', 'column 8');
hold on
hplt=plot(times, row8, 'r--', 'DisplayName', 'row 8');
hold on
hleg=legend('-DynamicLegend');
set(hleg, 'FontSize',10);
grid on
end
end
% Select which commands you would like to overlay on the centroid plot by
% choosing 'true', otherwise put 'false'
commands.nodA.toggle = true;
commands.nodB.toggle = true;
commands.nodX.toggle = true;
commands.dither.toggle = true;
commands.LOS.toggle = true;
commands.ta_pos_goto.toggle = true;
commands.coord_init.toggle = true;
commands.coord_correct.toggle = true;
x = 0:62;
N = numel(x);
nodA = rand(1,N);
nodB = 5.*rand(1,N)+5;
nodX = 50.*rand(1,N)-50;
dither = rand(1,N);
LOS = 5.*rand(1,N)+5;
ta_pos_goto = 50.*rand(1,N)-50;
coord_init = 5.*rand(1,N)+5;
coord_correct = 50.*rand(1,N)-50;
% This checks if the user-selected toggle is true and then plots the
% appropriate command times on the figure
if commands.nodA.toggle == true;
hplt = plot(nodA,times);
end
if commands.nodB.toggle == true;
hplt = plot(nodB,times);
end
if commands.nodX.toggle == true;
hplt = plot(nodX,times);
end
if commands.dither.toggle == true;
hplt = plot(dither,times);
end
if commands.LOS.toggle == true;
hplt = plot(LOS,times);
end
if commands.ta_pos_goto.toggle == true;
hplt = plot(ta_pos_goto,times);
end
if commands.coord_init.toggle == true;
hplt = plot(coord_init,times);
end
if commands.coord_correct.toggle == true;
hplt = plot(coord_correct,times);
end

Sign in to comment.

 Accepted Answer

I had an example much more like the following in mind...
x=1:10; y=rand(12,10); % make up some data to plot
l=cellstr(num2str([1:size(y,1)]')); % and labels for them...
ho=subplot(3,1,1:3); po=get(ho,'position') % To get the positions overall
po =
0.1300 0.1100 0.7750 0.8150
delete(ho) % don't want, just positions
for i=1:3 % plot some of y on each
i1=3*i-2;i2=3*i;
hs(i)=subplot(3,1,i);
plot(x,y(i1:i2,:))
legend(l(i1:i2)) % label the ones...
end
for i=1:3 % ok, now shrink the plots to make
p=get(hs(i),'position'); % room for the added axes to hold
p(3)=0.675; % the super legend
set(hs(i),'position',p)
end
hl=axes('position',[0.85 0.11 .105 0.815]); % and that axes
hlin=plot(hl,x,y); set(hlin,'visible','off'); % can't legend w/o lines
set(hl,'visible','off') % don't want to see axis
legend(hl,l) % and the global legends
That something like the effect you were looking for? (See how little actual was req'd to display something to look at, btw? I did get it into 20 lines! :) Try to pare your questions down to the essence instead of a whole application for somebody to try to wade through).
Obviously, I did some "magic numbers" of the sizes for the position; that's why I got the overall positions vector to begin with--I could look at those numbers and figure out a set of values to use to get the effect. You can use more sophisticated computational ways to generate them based on actual size and code there.
As always, "salt to suit..." :)
NB: I did NOT take the time to match the line styles; I just let them cycle automatically. If you control which style matches which line in the overall with those in each subplot then the legends will match, too.

More Answers (0)

Categories

Asked:

on 2 Aug 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!