x axis labels not properly working

조회 수: 4 (최근 30일)
KCE
KCE 2024년 2월 16일
답변: Walter Roberson 2024년 2월 16일
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