x axis labels not properly working
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
KCE
am 16 Feb. 2024
Beantwortet: Walter Roberson
am 16 Feb. 2024
I am having trouble getting the x axis tick marks and labels to display when I attempt to plot. Here is my code I am using. Everything else seems to work fine. The labels on the bottom x axis should be -0.08, -0.04, 0, 0.04, and 0.08.
%% Plotting section
figure;
%plot total hydrometeor mixing ratio differences
h1=plot((qr_diff(1,:)+qs_diff(1,:)+qg_diff(1,:)+qh_diff(1,:)).*1000,[1:50],'k-','LineWidth',4);
hold on;
%add a text label
text(-0.06,42,'d) total q','FontSize',42,'FontWeight','bold');
%axes properties
xlim([-0.08 0.08]);
xticks([-0.8:0.4:0.8]);
xticklabels({'-0.8';'-0.4';'0';'0.4';'0.8'});
xlabel('g kg^{-1}','FontSize',22,'FontWeight','bold');
aa = get(gca,'XTickLabel'); set(gca,'XTickLabel',aa,'FontSize',22,'FontWeight','bold');
ylim([0 50]);
yticks([0:10:50]);
yticklabels({'0';'10';'20';'30';'40';'50'});
ylabel('Model Level','FontSize',22,'FontWeight','bold');
bb = get(gca,'YTickLabel'); set(gca,'YTickLabel',bb,'FontSize',22,'FontWeight','bold');
set(gca,'TickDir','out');
set(gcf,'units','pixels','outerposition',[1 1 900 900],'windowstyle','normal')
% set inner position (plot box); force it square
set(gca,'units','normalized','position',[0.1300 0.1100 0.7750 0.8150],'plotboxaspectratio',[1 1 1])
saveas(gcf,[times(t,:),'_stincre_totq_vprof_',exps{nex},'.png'])
close
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1619283/image.png)
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 16 Feb. 2024
You used
xticks([-0.8:0.4:0.8]);
Instead of
xticks([-0.08:0.04:0.08]);
0 Kommentare
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!