I have some data which needs to be plotted in a bar plot.
My code is as follows:
x=[1:3,8];
y=[500 500 500 500
69 535 1354 42
97 498 1357 48
73 539 1328 60];
bar(x,y);
The output is as follows:
how to plot the graph so that there is no such space between 3 and 8 (as per the x-axis)?

 채택된 답변

Dyuman Joshi
Dyuman Joshi 2023년 10월 4일
편집: Dyuman Joshi 2023년 10월 4일

1 개 추천

Change the x values to categorical data type -
x=[1:3,8];
y=[500 500 500 500
69 535 1354 42
97 498 1357 48
73 539 1328 60];
x=categorical(x);
bar(x,y);
Another workaround is to plot serially and then change the tick-labels
x=[1:3,8];
y=[500 500 500 500
69 535 1354 42
97 498 1357 48
73 539 1328 60];
bar(1:numel(x),y);
xticklabels(x)

추가 답변 (0개)

카테고리

제품

릴리스

R2022b

태그

질문:

2023년 10월 4일

편집:

2023년 10월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by