Showing years on x axis graph

조회 수: 12 (최근 30일)
Egbert  Jansen
Egbert Jansen 2019년 7월 24일
답변: Stephan 2019년 7월 24일
This is my code. It displays the years with 2 year gaps.
How could I display it as 2018, 2019, 2020 etc
ExpRuleUncertaintyInterest.png
fig1 = figure;
pos_fig1 = [0 0 1250 1250];
set(fig1,'Position',pos_fig1)
for i = 1:6
subplot(3,2,i)
years = 2018:1:2032;
% yyaxis left;
p = plot(years,upperci{i}); hold on;
p2 = plot(years,mediandebt{i}); hold on;
p3 = plot(years,lowerci{i}); hold off;
ylim([((resultsminimadebt{i})-4) ((resultsmaximadebt{i})+2)]);
title(B(i));
xlabel('Year');
% yyaxis right;
% ylabel('%');
% yyaxis left;
ylabel('%');
p.LineWidth = 1;
p.Color = 'Red';
p.DisplayName = 'Debt ratio - Expenditure rule (99 CI, % of GDP)';
p.LineStyle = '--';
p2.LineWidth = 1;
p2.Color = 'Blue';
p2.DisplayName = 'Debt ratio - Expenditure rule (Median, % of GDP)';
p2.LineStyle = '-';
p3.Color = 'Red';
p3.DisplayName = 'Debt ratio - Expenditure rule (99 CI, % of GDP)';
p3.LineStyle = '--';
p3.LineWidth = 1;
X = ['ExpRuleUncertaintyInterestDebt', '.png'];
saveas(gcf,X);
end
legend('Orientation','horizontal','Box','off','FontSize',14,'NumColumns',1,'Position',[0.5 0.021 0.08 0.05]);
axes('Position', [0, 0.95, 1, 0.05] ) ;
set(gca, 'Color', 'None', 'XColor', 'None', 'YColor', 'None');
text( 0.5, 0, 'Simulating the impact of the proposed expenditure rule on debt with uncertainty in interest rates', 'FontSize', 16', 'FontWeight', 'Bold','HorizontalAlignment', 'Center', 'VerticalAlignment', 'Bottom');
X = ['ExpRuleUncertaintyInterestDebt', '.png'];
saveas(gcf,X);

답변 (1개)

Stephan
Stephan 2019년 7월 24일

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by