How to label each point in MatLab plot?

18 sec read

How to label each data point in a MatLab plot, like the following figure?

label data in MatLab plot
label data in MatLab plot

MatLab code:

x = [1:10];
y = x + rand(1,10);

figure('color','w'); plot(x,y,'o');
a = [1:10]'; b = num2str(a); c = cellstr(b);
dx = 0.1; dy = 0.1;
text(x+dx, y+dy, c);

It also works on 3D plot:

label data 3d
label data 3d

Adopted from

nirs2img, create an image file from NIRS data

Update 2021/2/27: If you find griddata3 not working, try to change griddata3 to griddata. I was asked where to get nirs2img script. Here it...
Xu Cui
51 sec read

mergefile.m – a MatLab script to merge CSV files

My wife asked me to write a script to merge some csv files she has. Usually this can be accomplished by a simple command in...
Xu Cui
35 sec read

xjview 9.6 released

In this version, we modified the templates for 3-D render view and use a high-resolution template. It also includes a few scalp view. You...
Xu Cui
31 sec read

2 Replies to “How to label each point in MatLab plot?”

Leave a Reply

Your email address will not be published. Required fields are marked *