To incorporate the shading between two curves into your existing code, you can enhance it by defining polygons for the shaded areas and rendering them with the “geom_polygon” method. Here are the additional lines you need to include in your original code to accomplish this:
% Calculate upper and lower bounds for 1 and 2 standard deviations
% Let control_mean and control_std to be the mean and standard deviation data of the control data that you mentioned you have
upper_bound_1std = control_mean + control_std;
lower_bound_1std = control_mean - control_std;
upper_bound_2std = control_mean + 2 * control_std;
lower_bound_2std = control_mean - 2 * control_std;
% Define polygons for the shaded areas
x_polygon = {cat(2, cycle, fliplr(cycle))};
y_polygon_1std = {cat(2, upper_bound_1std, lower_bound_1std)};
y_polygon_2std = {cat(2, upper_bound_2std, lower_bound_2std)};
% Define color for the shaded areas
green = [0 1 0];
% Initialisation is same as before
KNEE_Flex = cat(1,LKNEE_Strides,RKNEE_Strides);
ColorArray = cat(1,blue,red);
cycle = 0:1:100;
Knee_X_Mean = gramm('x', cycle', 'y', KNEE_Flex, 'color', ColorArray);
% Add shaded areas for 1 and 2 standard deviations
Knee_X_Mean.geom_polygon('x', x_polygon, 'y', y_polygon_2std, 'color', green, 'alpha', 0.2);
Knee_X_Mean.geom_polygon('x', x_polygon, 'y', y_polygon_1std, 'color', green, 'alpha', 0.4);
% Set color options and other properties
Knee_X_Mean.set_color_options('map', NMGcolormap);
Knee_X_Mean.set_names('x', '% cycle', 'y', 'degree');
Knee_X_Mean.set_title('Knee Flexion (+)');
Knee_X_Mean.geom_line;
% Draw the plot
Knee_X_Mean.draw();
You can find more information about “gramm” here:
Hope this helps.


