Reputation: 621
I am having a big problem in Matlab, because it seems that I want to do something that is not so usual.
Basically I am trying to implement a way of group distribution together called Vincentizing.In order to do that I am following the instruction of a paper (Ratcliff 1979 - Group Reaction Time Distributions and an Analysis of Distribution Statistics). Everything is fine until I have to plot the actual graph. I have an array that contains the quantiles of my dataset. The tutorial I am following says:
distribution histograms can be constructed by plotting quantiles on the abscissa and then constructing rectangles between adjacent quantiles such that all the rectangles have equal areas, as in Figure 2 (link of the image below)
http://postimg.org/image/btftrd6y7/
Once I calculate the quantiles, I can set the area to some value, let's say 10, and I can therefore calculate the height of each bar. The width of each bar is the distance between two adjacent quantiles, and of course I can calculate that as well. I have all the information I need, but I don't know how to plot a graph. How can, in matlab, plot I graph like the one in figure? (it seems that I can plot histogram of different width, but with the hist function I cannot actually specify the height. With the bar function, however, I can specify the height but it seems I cannot change the width..)
Every help is appreciated.
Upvotes: 3
Views: 5606
Reputation: 5073
The simplest solution is to use rectangle
:
% sample data: set the start of each bar, the bottom (here 0), the width and the height
x = [0.5 0.6 0.9 1 1.2]; % start of bar
y = zeros(length(x),1);
dx = diff([x 1.8]); % width of bar
dy = [1 3 2 .5 .1];
figure, hold on
for ii=1:length(x)
rectangle('position',[x(ii) y(ii) dx(ii) dy(ii)])
end
axis([0.5 2 0 4.1])
ylabel('Prob density')
xlabel('Time')
Upvotes: 3