Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Labelling scatter data points

I have a surface graph and on it I have plotted some points. Now I want to label each of these points. I used the following code.

name={'point1','point2','point3','point4','point5'}
co=[0 0 0];
scatter3(X,Y,Z,[],co,'filled');
c=cellstr(name);
dx = 0.1; dy = 0.1;
dz=0.1;
text(X+dx, Y+dy,Z+dz, c);

But the label data are not clear.
enter image description here

What can I do to make these labels clear?


Still after changing as 'Color', 'black', 'FontSize', 14) the labels are displayed as

enter image description here
Still they are not clear.

like image 506
sam_rox Avatar asked Sep 16 '26 13:09

sam_rox


2 Answers

ok now I got it: use set(gca,'SortMethod','childorder') I added an example below

    name={'<-point1','<-point2','<-point3','<-point4','<-point5'};
    co=[0 0 0];
    X  = repmat([1:10],1,10);
    Y  = sort(repmat([1:10],1,10));
    Z = X.*Y;

    X2 = repmat([1:10],10,1);
    Y2 = X2';
    Z2 = X2.*Y2;

    figure
    hold on 
    surf(X2,Y2,Z2);
    set(gca,'View',[-45 30])
    scatter3(X,Y,Z,[],co,'filled');

    c=cellstr(name);
    dx = 0.3; dy = -0.2;
    dz=0.1;
    %text(X(51:55)+dx, Y(51:55)+dy,Z(51:55)+dz, c,'BackgroundColor',[1 1 1]);
    text(X(51:55)+dx, Y(51:55)+dy,Z(51:55)+dz, c,'Color','white','Fontweight','bold');    
    scatter3(X(51:55),Y(51:55),Z(51:55),[],ones(5,3),'filled','MarkerEdgeColor','k');
    set(gca,'SortMethod','childorder')

enter image description here

enter image description here

like image 138
horseshoe Avatar answered Sep 18 '26 11:09

horseshoe


Use the background property of the text command:

text(0,1,'Hi the first point','background',[1 230/255 230/255]);

enter image description here

like image 32
NKN Avatar answered Sep 18 '26 11:09

NKN



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!