The ability to display a legend for an annotation object is not available in MATLAB.
A possible workaround is to create an invisible line object that has the same appearance as the annotation rectangle:
h = rectangle('Position',[0.59,0.35,3.75,1.37],...
'Curvature',0.8,...
'LineWidth',2,'LineStyle','--');
hline = line(NaN,NaN,'LineWidth',2,'LineStyle','--','Color',[0 0 0]);
legend(hline,'Rectangle')
Best Answer