如何在matlab中绘制不同高度和不同宽度的酒吧? [英] How to plot bar with different height and differenth width in matlab?

查看:135
本文介绍了如何在matlab中绘制不同高度和不同宽度的酒吧?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Matlab中遇到了一个大问题,因为它似乎是我想做的事情不那么平常。



基本上我试图实现一种方式的集体分配一起被称为Vincentizing。为了做到这一点,我遵循论文的指示()。一切都很好,直到我必须绘制实际的图。我有一个数组,其中包含我的数据集的分位数。我接下来的教程说:

分布直方图可以通过在横坐标上绘制分位数然后在相邻分位数之间构建矩形来构建,使得所有矩形具有相等的面积,在图2(下图中的链接)



http ://postimg.org/image/btftrd6y7/



一旦我计算分位数,我可以将该区域设置为某个值,比如说10,然后因此我可以计算每个小节的高度。每个条的宽度是两个相邻分位数之间的距离,当然我也可以计算出来。我掌握了所有我需要的信息,但我不知道如何绘制图表。在matlab中,如何绘制图形,如图所示?
(我似乎可以绘制不同宽度的直方图,但使用hist函数我实际上不能指定高度。但是,使用bar函数,我可以指定高度,但它似乎我不能改变宽度..)



每一个帮助表示赞赏。

解决方案

最简单的解决方案是使用矩形

 %sample data:设置每个小节的开始,底部(这里为0),宽度和高度

x = [0.5 0.6 0.9 1 1.2]; %开始吧
y =零(长度(x),1);
dx = diff([x 1.8]); %bar的宽度
dy = [1 3 2 .5 .1];


数字,对于ii = 1,持有
:length(x)
矩形('position',[x(ii)y(ii)dx ii)dy(ii)])
end
轴([0.5 2 0 4.1])$ ​​b
$ b ylabel('Prob density')
xlabel('Time' )


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.

解决方案

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')

这篇关于如何在matlab中绘制不同高度和不同宽度的酒吧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆