How to create a distance between labels in plot?

4 views (last 30 days)
How to separate the mixed labels? As show in figure. Below is my code.
clear all; close all; clc;
data=[0.0245,0.1200,0
0.0179,0.2700,4.1000
0.0224,0.2700,5.5000
0.0189,0.1000,3.3000
0.0219,0.1000,0.8000
0.0184,0.3500,0
0.0233,0.1000,2.7000
0.0230,0.1800,4.7000
0.0228,0.1800,4.7000
0.0185,0.2700,3.8000
0.0200,0.2700,4.4000
0.0182,0.2700,1.5000
0.0185,0.2700,4.7000
0.0203,0.1000,0
0.0171,0.1800,4.7000
0.0214,0.2700,1.8000
0.0199,0.3500,0
0.0202,0.2700,4.1000
0.0219,0.1200,5.4000
0.0196,0.3500,0
%0.0203,0.1000,0
0.0198,0.3500,0
0.0208,0.0700,0
];
x = data(:,1);
y = data(:,2);
z = data(:,3);
dz=1;
f=figure;
%t=tiledlayout("flow");
%nexttile(t);
h=scatter3(x,y,z,100,'filled','MarkerEdgeColor','k');
C = jet(numel(x));
h.CData = C;
set(gca, 'colormap', C)
colorbar()
%xlabel('${\it} (A^{2}/B)^{1/4}$','Interpreter','Latex')
xlabel('${\alpha }$','Interpreter','Latex')
ylabel('${\omega }$','Interpreter','Latex')
zlabel('${\varphi}$','Interpreter','Latex')
labels=["d1","d2","d3","d4","d5","d6","d7","d8","d9","p1","p2","p3","p4","v1,v8","v2","v3","v4","v5","v6","v7","v9","v10"];
text(x,y,z+dz,labels,"HorizontalAlignment","center","VerticalAlignment","bottom",'FontSize',10);

Accepted Answer

Mathieu NOE
Mathieu NOE on 13 Jan 2022
hello haya
I have introduced a bit of randomness in the dz so that the labels will be a different heights
dz = 0.2+0.5*rand(size(z));
of course you can adapt the fixed and variable amplitudes so it best matches your expectations
clear all; close all; clc;
data=[0.0245,0.1200,0
0.0179,0.2700,4.1000
0.0224,0.2700,5.5000
0.0189,0.1000,3.3000
0.0219,0.1000,0.8000
0.0184,0.3500,0
0.0233,0.1000,2.7000
0.0230,0.1800,4.7000
0.0228,0.1800,4.7000
0.0185,0.2700,3.8000
0.0200,0.2700,4.4000
0.0182,0.2700,1.5000
0.0185,0.2700,4.7000
0.0203,0.1000,0
0.0171,0.1800,4.7000
0.0214,0.2700,1.8000
0.0199,0.3500,0
0.0202,0.2700,4.1000
0.0219,0.1200,5.4000
0.0196,0.3500,0
%0.0203,0.1000,0
0.0198,0.3500,0
0.0208,0.0700,0
];
x = data(:,1);
y = data(:,2);
z = data(:,3);
dz = 0.2+0.5*rand(size(z));
f=figure;
%t=tiledlayout("flow");
%nexttile(t);
h=scatter3(x,y,z,100,'filled','MarkerEdgeColor','k');
C = jet(numel(x));
h.CData = C;
set(gca, 'colormap', C)
colorbar()
%xlabel('${\it} (A^{2}/B)^{1/4}$','Interpreter','Latex')
xlabel('${\alpha }$','Interpreter','Latex')
ylabel('${\omega }$','Interpreter','Latex')
zlabel('${\varphi}$','Interpreter','Latex')
labels=["d1","d2","d3","d4","d5","d6","d7","d8","d9","p1","p2","p3","p4","v1,v8","v2","v3","v4","v5","v6","v7","v9","v10"];
text(x,y,z+dz,labels,"HorizontalAlignment","center","VerticalAlignment","bottom",'FontSize',10);

More Answers (0)

Categories

Find more on Colormaps in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!