Help for xtick label

조회 수: 8 (최근 30일)
Emanuele D'Amato
Emanuele D'Amato 2020년 9월 9일
댓글: Emanuele D'Amato 2020년 9월 9일
Hi everybody, I hope i'm writing in the right place. I need your help to fix a problem with an XTick label. I want the lower X Axis to have 5 ticks, the same number of data i have to plot, but when i run the code it shows only 4 ticks out of 5!
Here the code and the image of the plot.
I'm using 2020.a version
___________________________________________________________________________________________________________________________
close all
clear all
clc
hAxes.TickLabelInterpreter = 'latex';
V=100:50:300
vv=V/3.6
nu=1.5e-5;
L=4.5;
Re=vv*L/nu;
Cx_originale = [0.5241 0.5314 0.5424 0.5407 0.5427];
plot(Re,Cx_originale,'.k','MarkerSize',20);
xlabel('Reynolds','FontSize',20)
ylabel('$C_x$','Interpreter','latex','Rotation',0,'FontSize',25)
axis([0.8333e7 2.5e7 0.5 0.65])
hold on
hAx1=gca;
hAx1.YLim= [0.5 , 0.65]
xticklabels({'8.33\cdot 10^6','1.25\cdot 10^7','1.67\cdot 10^7','2.08\cdot 10^7','2.5\cdot 10^7'})
a = get(gca,'XTickLabel');
set(hAx1,'XTickLabel',a,'FontName','Times','fontsize',15)
hAx2=axes('Position',hAx1.Position, ...
'XAxisLocation','top', ...
'YAxisLocation','right', ...
'Color','none', ...
'YTick',[])
xlim(hAx2,[100,300])
set(hAx2,'XTick',[100:50:300])
a = get(gca,'XTickLabel');
set(gca,'XTickLabel',a,'FontName','Times','fontsize',15)
xlabel(hAx2,'Velocity [Km/h]','FontSize',20)

채택된 답변

Alan Stevens
Alan Stevens 2020년 9월 9일
편집: Alan Stevens 2020년 9월 9일
Add this line just above your xticklabels line.
hAx1.XTick=[8.3333*10^6 1.25*10^7 1.67*10^7 2.08*10^7 2.5*10^7];
  댓글 수: 1
Emanuele D'Amato
Emanuele D'Amato 2020년 9월 9일
It perfectly worked! thank you a lot, you saved me!
Have a nice day

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by