필터 지우기
필터 지우기

How can I set the histogram width

조회 수: 2 (최근 30일)
Minhee
Minhee 2023년 11월 27일
댓글: Minhee 2023년 11월 27일
I want same distance between each bars. Now the distance between 1 and 10 is closer than that between 10 and 50 or 50 and 100.
How can I edit the graph?

답변 (1개)

Cris LaPierre
Cris LaPierre 2023년 11월 27일
편집: Cris LaPierre 2023년 11월 27일
You will need to turn your System Size values into categoricals. You haven't shared your data, so here's a simple example.
% What you currently have
systemSize = ([ones(4200,1);10*ones(500,1);50*ones(100,1);100*ones(50,1)]);
histogram(systemSize)
xticks([1 10 50 100])
% With x data type as categoricals
catSystemSize = categorical(systemSize);
histogram(catSystemSize)
  댓글 수: 5
Cris LaPierre
Cris LaPierre 2023년 11월 27일
Your code is fine, except that you still need to convert your X values to categoricals. This allows the x position to be set by group number instead of numeric value.
This is the only line of code that needs to change.
bar(categorical(system_sizes), all_capex_values, 'grouped');
Minhee
Minhee 2023년 11월 27일
Thank you so much!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Linear Model Identification에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by