Select Git revision
mainrocketplot.m
-
giuliaghirardini authoredgiuliaghirardini authored
mainrocketplot.m 1.52 KiB
close all
clear
clc
%%
mission = Mission('design');
mission2 = Mission('design');
rocket = Rocket(mission);
rocket2 = Rocket(mission2);
r = rocketPlot(mission, rocket);
r2 = rocketPlot(mission2, rocket2);
%% Merging Figures
% Get axes from both figures
first_ax = findobj(r, 'type', 'axes');
second_ax = findobj(r2, 'type', 'axes');
% Modify the appearance of the second rocket's plot
ch2 = get(second_ax, 'children'); % Get children of second figure's axes
for i = 1:length(ch2)
if isprop(ch2(i), 'Color') % Check if the child has a 'Color' property
set(ch2(i), 'Color', 'blue', 'LineStyle', '--'); % Set color to blue, dashed line
end
end
% Create a new figure for the merged content
merged_fig = figure('Name', 'Merged Figure');
merged_ax = axes(merged_fig); % Create new axes in the merged figure
% Copy the children from the first figure's axes
ch1 = get(first_ax, 'children'); % Direct children only
copyobj(ch1, merged_ax); % Copy to merged axes
% Copy the modified children from the second figure's axes
copyobj(ch2, merged_ax); % Copy to merged axes
% Set up legend with correct colors
legend_labels = [ch1(1), ch2(1)]; % Use the first plot from each figure for the legend
legend(merged_ax, legend_labels, ...
{string(strrep(mission.name, '_', ' ')), string(strrep(mission2.name, '_', ' '))}, ...
'Location', 'best');
% Adjust labels and appearance
xlabel(merged_ax, 'Merged X-axis Label');
ylabel(merged_ax, 'Merged Y-axis Label');
title('Rocket Comparison');
axis equal
disp('Figures merged successfully.');