It's going to look real messy when you have high resolution x and y data.
[x,y,z]=peaks(20);
[~,c]=contourf(x,y,z);hold on
set(gca,'XTick',[],'YTick',[]);
C = reshape([x(:)'; y(:)'], [], 1)';
str=sprintf('[%.2g;%.2g],',C);
str=strsplit(str,',')
str(end) = [];
text(x(:),y(:),str(:),'fontsize',6,'horizontalalignment','center','verticalalignment','mid')
Or alternatively, with the undocumented sprintfc (courtesy Walter Roberson)
str=sprintfc('[%.2g;%.2g]',C);
text(x(:),y(:),str(:),'fontsize',6,'horizontalalignment','center','verticalalignment','mid')
Best Answer