如何在 MATLAB 中绘制水平直方图?
我查了一下,找不到这个问题的答案,所以就在这里。
我有一些数据(称为数据的 1 X 1000 向量),我想为其绘制直方图信息。如果我使用 histogram(data)
命令,那么我会得到一个足够好的直方图,其中 x 轴均匀地分为十个桶(最大值和最小值之间的十个相等间隔的中点值)数据的数量),y 轴记录每个存储桶出现的次数。
我真正想要的是相同的图,只是 y 轴代表存储桶间隔,x 轴代表每个存储桶的计数...
这样我可以将其粘贴到一些其他信息旁边的子图中,并且一切都会变得更容易理解(并且看起来超级酷)。有什么简单的方法可以实现这一点?谢谢!
I looked and couldn't find an answer for this question, so here goes.
I have some data (a 1 X 1000 vector called data) that I would like to plot the histogram information for. If I use the histogram(data)
command then I get a nice enough histogram plot where the x-axis is the divided evenly into ten buckets (midpoint values of the ten equal intervals between the max and min values of the data) and the y-axis records how many occurances occured for each bucket.
What I really want is the same plot, just with the y-axis representing the bucket intervals, and the x-axis representing the count for each bucket...
That way I can stick it into a subplot next to some other information, and everything will be easier to understand (and look super cool). What's an easy way to accomplish this? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用
barh
功能。下面是一个示例:翻转条形图
下面的示例展示了如何沿垂直轴翻转图表。
You can achieve what you want using the
barh
function. Here's an example:Flipping the bar chart
Here's an example showing how to flip the chart along a vertical axis.
由于引入了 HISTOGRAM 函数(R2014b),您可以通过将 'orientation' 设置为 'horizontal' 来制作水平直方图
示例:
since the HISTOGRAM function was introduced (R2014b), you can make a horizontal histogram by setting 'orientation' to 'horizontal'
example:
您还可以使用常规直方图函数 hist,然后通过键入更改观点
You can also use the regular histogram function hist and then change the point of view by typing