Bar plot of categorical data
1 次查看(过去 30 天)
显示 更早的评论
Hi!
I have a small column vector (46x1). Each row has a number (0-7), where each number encodes a specific electrode location. I want to create a bar plot essentially with the relative (or absolute) frequency of each number. Therefore something like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1322960/image.png)
If if use the histogram() function, then it only plots a line connecting the dots
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1322965/image.png)
And if I use bar() function, then it plots each row individually.
Can you please help? thank you!
0 个评论
采纳的回答
Voss
2023-3-13
histogram seems to work fine:
data = randi([0,7],46,1);
histogram(data)
Maybe you have another function called histogram that's being run instead. Do
which histogram -all
to see which histogram functions you have, and if there are any besides the built-in, rename them to something else.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Histograms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!