sam*_*rox 2 matlab surface scatter-plot
我有一个曲面图,在上面绘制了一些点。现在我想给每一点贴上标签。我使用了以下代码。
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);
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能使这些标签变得清晰?
仍然在更改后 'Color', 'black', 'FontSize', 14)
标签显示为
好的,现在我明白了:使用set(gca,'SortMethod','childorder')
我在下面添加了一个示例
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')
Run Code Online (Sandbox Code Playgroud)