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