How can i set gap between two xlabels created by text

How can i create gap between bottom two labels.
It has two problems:
1) I want to create 11 tick marks on x-axis.
2) I want to create vertical gap between text line of "Angle" and "Number".
Ej_plot=(2.*180.*(jn-1)./Z); % jn=1:11, Z=11
tp=1:11;
figure(3);
xlim([0 Ej_plot(1,end)]);
ymin = min(ylim);
yrng = diff(ylim);
set(gca, 'XTickLabel', []);
nrxt = 11;
lat_txt = cellstr(strsplit(num2str(Ej_plot,'%.2f '),' '));
text([(Ej_plot(1)-Ej_plot(2))*0.5 Ej_plot], ones(1,nrxt+1)*ymin-0.05*yrng, ['Angle ' lat_txt],'HorizontalAlignment','center','Rotation',45)
lng_txt = cellstr(strsplit(num2str(tp),' '));
text([(Ej_plot(1)-Ej_plot(2))*0.5 Ej_plot], ones(1,nrxt+1)*ymin-0.1*yrng, ['Number ' lng_txt],'HorizontalAlignment','center')

 Accepted Answer

Like so perhaps:
Ej_plot=(2.*180.*(jn-1)./Z); % jn=1:11, Z=11
tp=1:11;
h = figure(3);
xlim([0 Ej_plot(1,end)]);
ymin = min(ylim);
yrng = diff(ylim);
set(gca, 'XTickLabel', []);
nrxt = 11;
lat_txt = cellstr(strsplit(num2str(Ej_plot,'%.2f '),' '));
text([(Ej_plot(1)-Ej_plot(2))*0.5 Ej_plot], ones(1,nrxt+1)*ymin-0.05*yrng, ['Angle ' lat_txt],'HorizontalAlignment','center','Rotation',45)
lng_txt = cellstr(strsplit(num2str(tp),' '));
text([(Ej_plot(1)-Ej_plot(2))*0.5 Ej_plot], ones(1,nrxt+1)*ymin-0.15*yrng, ['Number ' lng_txt],'HorizontalAlignment','center')
h.CurrentAxes.Position = [0.1300 0.16000 0.7750 0.8200];

5 Comments

Yes they are. You had
text([(Ej_plot(1)-Ej_plot(2))*0.5 Ej_plot], ones(1,nrxt+1)*ymin-0.1*yrng, ['Number ...
I used ||||
text([(Ej_plot(1)-Ej_plot(2))*0.5 Ej_plot], ones(1,nrxt+1)*ymin-0.15*yrng, ['Number ...
Thank you very much... It works...
Moreover, it is required to keep text named "Angle" horizontal... How can i do this? But, the angles specified as 0.00, 32.73, etc.. should be inclined. Please reply
Try
Ej_plot=(2.*180.*(jn-1)./Z); % jn=1:11, Z=11
tp=1:11;
h = figure(3);
xlim([0 Ej_plot(1,end)]);
ymin = min(ylim);
yrng = diff(ylim);
set(gca, 'XTickLabel', []);
nrxt = 11;
lat_txt = cellstr(strsplit(num2str(Ej_plot,'%.2f '),' '));
text([(Ej_plot(1)-Ej_plot(2))*0.5 Ej_plot], ones(1,nrxt+1)*ymin-0.05*yrng, [' ',lat_txt],'HorizontalAlignment','center','Rotation',45)
lng_txt = cellstr(strsplit(num2str(tp),' '));
text([(Ej_plot(1)-Ej_plot(2))*0.5 Ej_plot], ones(1,nrxt+1)*ymin-0.15*yrng, ['Number ' lng_txt],'HorizontalAlignment','center')
h.CurrentAxes.Position = [0.1300 0.16000 0.7750 0.8200];
text(-40,ymin-0.05*yrng,'Angle')

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!