How can I move the bars in a bar chart?

조회 수: 51 (최근 30일)
Catayoun Lissa Eleonore Azarm
Catayoun Lissa Eleonore Azarm 2021년 1월 12일
답변: David Hill 2021년 1월 12일
Hey! can someone help me? i want my graph to look like the 2nd one, but it looks like the first. so the bars are moved. and i dont kno how to move them.Greets
  댓글 수: 4
the cyclist
the cyclist 2021년 1월 12일
It would be easiest to help you if you uploaded both the data and the code that generated your figure, so that we can see exactly how you did it, recreate the figure, and help you fix it.
If that is not possible for some reason, at the very least please post the commands you used to plot the bars, plot the line, and create the x-axis labels.
Adam Danz
Adam Danz 2021년 1월 12일
As the cyclist pointed out, we don't know how your plots were created so we can't be certain what's wrong.
For example, are the month labels a result of specifying xtick and xticklabel or are your data categorical or datetime values?
My guess is that you're specifying x-ticks with datetime values but the x-values are not on the first day of the month. The problem could be fixed using dateshift to shift the dates to the 1st of the month but there are better ways such as specifying xtickformat.

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

답변 (1개)

David Hill
David Hill 2021년 1월 12일
figure;
bar_displacement=.25;%play with this until it is correct
bar(x-bar_displacement,y);
set(gca,'XTick', x);

카테고리

Help CenterFile Exchange에서 Axes Appearance에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by