フィルターのクリア

Xticklabels error too many input arguments

9 ビュー (過去 30 日間)
Nadja
Nadja 2023 年 2 月 26 日
コメント済み: Walter Roberson 2023 年 2 月 26 日
I have a time series for the years 1993-2003 which i want to extend to 1993-2010
My code for the table 1993-2003 is
x = linspace(1,11,11);
y = percentincomeriskshared93_03;
yyaxis left
plot(x,y)
ytickformat('percentage')
ylabel('Percent of Risk Shared')
z = meanoflogassets_gdp_93_03;
yyaxis right
plot(x,z)
ylim([-0.8,0.4])
ylabel('Natural Log. of (assets/GDP)')
xticks([ 1 2 3 4 5 6 7 8 9 10 11])
xticklabels({'1993','1994', '1995', '1996', '1997', '1998','1999','2000', '2001','2002','2003'})
title('Income risk sharing and foreign asset holdings in the OECD 1993-2003')
I want to do the same for 1993-2010 and i just changed xticks to 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
and xticklabels to 1993 until 2010
but then I get the error "too many input arguments". Is there an alternative for xticklabels or is it really not possible to label the x axis according to 18 years?
  1 件のコメント
Walter Roberson
Walter Roberson 2023 年 2 月 26 日
What shows up for
which -all xticklabels

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2023 年 2 月 26 日
Try this:
x = linspace(1,11,11);
y = rand(1, numel(x)); %percentincomeriskshared93_03;
yyaxis left
plot(x, y, 'r.-', 'LineWidth', 2, 'MarkerSize', 24);
ytickformat('percentage')
ylabel('Percent of Risk Shared')
meanoflogassets_gdp_93_03 = rand(1, length(x));
z = meanoflogassets_gdp_93_03;
yyaxis right
plot(x, z, 'b.-', 'LineWidth', 2, 'MarkerSize', 24)
% ylim([-0.8,0.4])
ylabel('Natural Log. of (assets/GDP)')
% Set up tick labels along the x axis.
xticks(1:18)
xAxisLabels = {'1993','1994', '1995', '1996', '1997', '1998','1999','2000', ...
'2001','2002','2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010'};
whos xAxisLabels % Should be 1x18
Name Size Bytes Class Attributes xAxisLabels 1x18 2016 cell
xticklabels(xAxisLabels)
title('Income risk sharing and foreign asset holdings in the OECD 1993-2010')
% Extend the graph beyond the last x so we can see the other tick labels.
% There is no data plotted for years 2004-2010 so there will be no markers there!
xlim([1, 18])
grid on;

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGrid Lines, Tick Values, and Labels についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by