Help for xtick label

2 vues (au cours des 30 derniers jours)
Emanuele D'Amato
Emanuele D'Amato le 9 Sep 2020
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)

Réponse acceptée

Alan Stevens
Alan Stevens le 9 Sep 2020
Modifié(e) : Alan Stevens le 9 Sep 2020
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 commentaire
Emanuele D'Amato
Emanuele D'Amato le 9 Sep 2020
It perfectly worked! thank you a lot, you saved me!
Have a nice day

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by