
Help for xtick label
3 次查看(过去 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!