
Help for xtick label
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Emanuele D'Amato
am 9 Sep. 2020
Kommentiert: Emanuele D'Amato
am 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)
0 Kommentare
Akzeptierte Antwort
Alan Stevens
am 9 Sep. 2020
Bearbeitet: Alan Stevens
am 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];

Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Axis Labels finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!