필터 지우기
필터 지우기

Remove white space around a horizontal bar

조회 수: 9 (최근 30일)
Aksh Chordia
Aksh Chordia 2023년 7월 27일
편집: Nathan Hardenberg 2023년 7월 27일
I want to remove the vertical space above and below the graph, but I cannot find the function for that. Could someone please help?
I am using the "barh" function to create these figures.
My figure looks like this:
I want to make it look like this:
remove the not used white space, but the legend should be there.
Thanks
Aksh
  댓글 수: 1
Dyuman Joshi
Dyuman Joshi 2023년 7월 27일
You can adjust the y limits via ylim but in that case the axes won't come in, the bar will be stretched out to fill the gap.

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

답변 (1개)

Nathan Hardenberg
Nathan Hardenberg 2023년 7월 27일
편집: Nathan Hardenberg 2023년 7월 27일
Adjusting the bar width should work. Just choosing a big number is maybe good enough.
x = [0]; % data
y = [15 20 5]; % data
figure(); % create figure
width=550; height=60; % configure dimensions
set(gcf,'position',[0, 0, width, height])
barh(x, y, 100, 'stacked') % plot with adjusted bar width (= 100)
--EDIT--
And if you want to remove the numbers and ticks you can do (source):
figure(); % create figure
width=550; height=60; % configure dimensions
set(gcf,'position',[0, 0, width, height])
barh(x, y, 100, 'stacked') % plot with adjusted bar width (= 100)
set(gca, 'box','off','XTickLabel',[],'XTick',[],'YTickLabel',[],'YTick',[])

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by