
Help for xtick label
1 回表示 (過去 30 日間)
古いコメントを表示
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)
0 件のコメント
採用された回答
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];

その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Axis Labels についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!