Bar plot of categorical data

6 ビュー (過去 30 日間)
Panos Kerezoudis
Panos Kerezoudis 2023 年 3 月 13 日
コメント済み: Voss 2023 年 3 月 14 日
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:
If if use the histogram() function, then it only plots a line connecting the dots
And if I use bar() function, then it plots each row individually.
Can you please help? thank you!

採用された回答

Voss
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.
  2 件のコメント
Panos Kerezoudis
Panos Kerezoudis 2023 年 3 月 14 日
thank you! that was the issue. problem, fixed!
Voss
Voss 2023 年 3 月 14 日
You're welcome! Glad it's working now.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeHistograms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by