I would like to know how to remove the patcharea being represented in legend. I have attached the code and outputs when patch command is included and not used. When patch is used to highlight a portion of plot its color is getting indicated rather than the linestyle and line color in legend. Also the thickening of xaxis and yaxis in upper and right side borders disappears when more than one patch command has used. This can be seen from the figure named patch. Please let me know how to fix this issue. Due to the limitation on number of pictures can be attached i have added the picture when patch command is used.
Edit: Through the usage of handles legend issue got solved. But the boder issue persists. Have a look at the picture named patch1 in comments.
clc;clear all;close all;x = linspace(-10,10,200); y = sin(4*x);y1 = sin(x);figure;patch([2 5 5 2], [[1 1]*(-1) [1 1]*(1)], 'y', 'FaceAlpha',0.3, 'EdgeColor','none');hold onpatch([-5 -2 -2 -5], [[1 1]*(-1) [1 1]*(1)], 'y', 'FaceAlpha',0.3, 'EdgeColor','none');hold onplot(x,y,'r');hold onplot(x,y1,'g');hold offgrid on;legend({'sin(4*x)','sin(x)'});
Best Answer