How I can plot this bar graph

1 次查看(过去 30 天)
Arsal15
Arsal15 2016-2-28
编辑: Stephen23 2016-2-29
This bar graph shows on y axis the time and on x axis the number of points.
I want to plot this bar graph as such that it gives accumulated value of 0.8 entries and 0.9 entries like histogram do. Mean its thickness remain same but its height increases with accumulation of entries. for 0.8 it shows height 10 and for 0.9 it shows height 6.
Actually in my problem set 0.8 and 0.9 are the time axis and this 10 and 6 represents the number of data packet generated in that time instant. like 0.8 comes first so at 0.8 time instant 10 data packets generated and at 0.9 time instant 6 data packet and so on..
I hope this will help in understanding what I want to do. I just want to work like histogram using bar plot. so I want to automatically plot the data set using bar graph.

回答(1 个)

Stephen23
Stephen23 2016-2-29
编辑:Stephen23 2016-2-29
If the values were integer then it would be possible using unique, but because you have floating-point values I would recommend that you use John D'Errico's very neat FEX submission consolidator:
tol = 0.05;
Y = [0.8,0.8,0.8,0.8,0.9,0.8,0.9,0.9,0.9,0.8,0.8,0.9,0.8,0.9,0.8,0.8,0.9];
[~,ycon,ind] = consolidator(Y,[],'count',tol);
bar(1:numel(ind),ycon(ind))
If you have a newer version of MATLAB you could alternatively use uniquetol.

类别

Help CenterFile Exchange 中查找有关 Bar Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by