2D Plotting With Non Numeric X Axis
22 ビュー (過去 30 日間)
古いコメントを表示
I want to plot 2 dimensional data lets say monthly income. My problem is the values of the x axis which are non numeric. On the y axis I want income and along the x axis months expressed as Jan, Feb, .... Lets assume I read the data from an ordinary textfile where each row contains month and income. How do I get the plot that I want?
0 件のコメント
採用された回答
Image Analyst
2014 年 4 月 13 日
Plot y as usual with a bar() or plot() function call, then change the numerical labels from 1 - 12 to months:
set(gca,'XTickLabel',{'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'})
0 件のコメント
その他の回答 (1 件)
Sven
2014 年 4 月 13 日
Hi Dan,
Try this code, there's a dateaxis command perfect for what you want:
xVals = datenum(0,1:12,1); % The first day of jan,feb,etc.
yVals = 2.^(1:12); % Exponentially growing income!
figure, plot(xVals,yVals)
dateaxis('x',3) % See "doc dateaxis" for more options
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Descriptive Statistics and Visualization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!