HOW DO I ADD SPACES IN BETWEEN THE POINTS OF X AXIS IN THE BAR GRAPH WHICH IS GENERATED BY MATLAB?

1 回表示 (過去 30 日間)
char S
char S 2014 年 9 月 16 日
回答済み: Image Analyst 2014 年 9 月 16 日
HOW DO I ADD SPACES IN BETWEEN THE POINTS OF X AXIS IN THE BAR GRAPH WHICH IS GENERATED BY MATLAB?
X AXIS VALUES ARE: x=[400 430 540 560 330 340 450 400 300 200 ];
Y = [6 4 7 9 1 2 6 1 1 9 5 8 8 1 7 7 1 1 8 1 5 8 8 5 9 1 1 5 1 2]; PLS REPLY
  1 件のコメント
dpb
dpb 2014 年 9 月 16 日
編集済み: dpb 2014 年 9 月 16 日
How to unlock CAPLOCK Key???
How, specifically, did you generate a bar graph from the above data with differing length series?
>> x=[400 430 540 560 330 340 450 400 300 200 ];
Y = [6 4 7 9 1 2 6 1 1 9 5 8 8 1 7 7 1 1 8 1 5 8 8 5 9 1 1 5 1 2];
>> bar(x,Y)
Error using bar (line 55)
X must be same length as Y.
>>
Well, let's try to fixup that to see what get by default...
>> bar(x,Y(1:length(x)))
Error using bar (line 60)
XData cannot contain duplicate values.
>>
So, that isn't workable, either.
Looking at x somewhat more critically, it isn't in ascending order, either, which, while not impossible, isn't likely what would produce a desirable plot.
So, need a lot of work on the data underlying question it would seem, besides the edit.

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

回答 (1 件)

Image Analyst
Image Analyst 2014 年 9 月 16 日
Try this:
Y = [6 4 7 9 1 2 6 1 1 9 5 8 8 1 7 7 1 1 8 1 5 8 8 5 9 1 1 5 1 2];
x = 1 : length(Y); % Because yours was totally messed up.
bar(x, Y, 'BarWidth', 0.6);
Vary the BarWidth of 0.6 between 0 and 1 to get different spaces between the bars if you want to change it.

カテゴリ

Help Center および File ExchangeSpecifying Target for Graphics Output についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by