필터 지우기
필터 지우기

bar plot cannot spread x axis homogeneously

조회 수: 2 (최근 30일)
sermet OGUTCU
sermet OGUTCU 2019년 7월 15일
답변: Star Strider 2019년 7월 15일
imp_2d_E=[0 -1;0 0;0 3;0 0;0 0;0 0;0 0;2 3;0 0;1 0;0 0;0 1;0 0;0 0;1 0;0 0;1 1;0 0;2 2;0 0];
bar(imp_2d_E)
set(gca,'XTick',[]);
xtl = {'ALIC','AMC4','BOGT','BSHM','CPVG','DAV1','KZN2','LPGS','MADR','MCM4','MIZU','NAUR','NKLG','PALM','PIMO','SAMO','SUTH','TRO1','URUM','YEL2'};
xtnew = linspace(1, numel(xtl), numel(xtl));
set(gca, 'XTick',xtnew, 'XTickLabel',xtl, 'XTickLabelRotation',90);
title('2D improvement (cut-off:5)','FontWeight','bold','FontSize',22);
xlabel('STATIONS', 'FontWeight', 'bold','FontSize',20);
ylabel('millimeter ', 'FontWeight','bold','FontSize',20)
legend('24h','12h');
set(gca,'FontWeight','bold')
set(gca,'fontsize',20)
ylim([-2 4])
When executing the above codes, x axis cannot be homogeneously spreaded and unreasonable space from the right side has remained. How can I correct this limitation?
  댓글 수: 1
Adam Danz
Adam Danz 2019년 7월 15일
편집: Adam Danz 2019년 7월 15일
The code you shared doesn't reproduce the problem when I run it (r2019a). The image below is the result of your code and I added the "grid on" command. Are you sure you're not setting the xlim() somewhere?

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

채택된 답변

Star Strider
Star Strider 2019년 7월 15일
Either add a xlim call, or define both axes limits at the same time, and replace your ylim call with an axis call:
axis([0 20 -2 4])

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by