x=0:pi/100:2*pi;
y=2*exp(-0.5*x).*sin(2*pi*x);
h1=plot(x,y);
hc=uicontextmenu;
h1s=uimenu(hc,'Text','线形');
h1w=uimenu(hc,'Text','线宽');
uimenu(h1s,'Text','虚线','Callback','set(h1,''LineStyle'','':'');');
uimenu(h1s,'Text','实线','Callback','set(h1,''LineStyle'',''-'');');
uimenu(h1w,'Text','粗','Callback','set(h1,''LineWidth'',2);');
uimenu(h1w,'Text','细','Callback','set(h1,''LineWidth'',0.5);');
set(h1,'UIContextMenu',hc)