HOW DO I ADD SPACES IN BETWEEN THE POINTS OF X AXIS IN THE BAR GRAPH WHICH IS GENERATED BY MATLAB?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
dpb
el 16 de Sept. de 2014
Editada: dpb
el 16 de Sept. de 2014
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.
Respuestas (1)
Image Analyst
el 16 de Sept. de 2014
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.
0 comentarios
Ver también
Categorías
Más información sobre Specifying Target for Graphics Output en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!