필터 지우기
필터 지우기

Bar plot of categorical data

조회 수: 1 (최근 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 CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by