x axis labels not properly working

4 次查看(过去 30 天)
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);
Unrecognized function or variable 'qr_diff'.
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

采纳的回答

Walter Roberson
Walter Roberson 2024-2-16
You used
xticks([-0.8:0.4:0.8]);
Instead of
xticks([-0.08:0.04:0.08]);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Axis Labels 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by