# enter values from 0 to N (imposed value) with step of 100 on the x-axis of the bar graph

조회 수: 1 (최근 30일)
Alberto Acri . 2023년 8월 24일
댓글: Mathieu NOE . 2023년 8월 24일
Hi. I need to change the values on the x-axis of a bar graph.
I have tried in the following way but it doesn't seem to work. Why? How can I enter values from 0 to 700 (imposed value) with step of 100 on the x-axis of the bar graph?
matrix = [64 440; 65 489; 66 581; 67 563];
figure
hbh = barh(matrix(:,1), matrix(:,2));
N = 700;
step = 100;
vector_x_axis = 0:step:N;
xticks(vector_x_axis)

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

### 채택된 답변

Mathieu NOE 2023년 8월 24일
hello Alberto
welcome back !
i suppose you wanted to do this
matrix = [64 440; 65 489; 66 581; 67 563];
figure
hbh = barh(matrix(:,1), matrix(:,2));
N = 700;
% step = 100;
% vector_x_axis = 0:step:N;
% xticks(vector_x_axis)
xlim([0 N]) ##### 댓글 수: 4이전 댓글 3개 표시이전 댓글 3개 숨기기
Mathieu NOE 2023년 8월 24일
my pleasure !

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

### 추가 답변 (1개)

Kevin Holly 2023년 8월 24일
I'm not exactly sure what you want to see. Are one of the 3 graphs below what you want?
matrix = [64, 440; 65, 489; 66, 581; 67, 563];
N = 700;
step = 100;
vector_x_axis = 0:step:N;
figure
hbh = barh(matrix(:, 1), matrix(:, 2));
xlim([0 700]) figure
hbh = barh(matrix(:, 1), matrix(:, 2));
xticks(vector_x_axis)
xticklabels(vector_x_axis(2:end)) figure
hbh = barh(matrix(:, 1), matrix(:, 2));
xticks(vector_x_axis)
step = 700/6;
vector_x_axis = 0:step:N;
xticklabels(vector_x_axis) ##### 댓글 수: 2이전 댓글 1개 표시이전 댓글 1개 숨기기
Kevin Holly 2023년 8월 24일
I'm still not quite sure what you want.
matrix = [64, 440; 65, 489; 66, 581; 67, 563];
N = 700;
step = 50;
vector_x_axis = 0:step:N;
figure
hbh = barh(matrix(:, 1), matrix(:, 2));
xticks(vector_x_axis) figure
hbh = barh(matrix(:, 1), matrix(:, 2));
xticks(vector_x_axis)
xlim([0 700]) 댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

R2021b

### Community Treasure Hunt

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

Start Hunting!