function WriteText(x,y,txtline,color) % WriteText: with back color Can be specified in Matlab 6.5) % % Write the text to get the size ht = text(x,y,txtline,'VerticalAlignment','top'); pos = get(ht,'Extent'); xp =[ pos(1) pos(1)+pos(3) pos(1)+pos(3) pos(1)]; yp =[ pos(2) pos(2) pos(2)+pos(4) pos(2)+pos(4)]; patch(xp,yp,color,'EdgeColor',[1 1 1]) ht = text(x,y,txtline,'VerticalAlignment','top');