Remove white space around a horizontal bar
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1443417/image.png)
I want to make it look like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1443422/image.png)
remove the not used white space, but the legend should be there.
Thanks
Aksh
1 commentaire
Dyuman Joshi
le 27 Juil 2023
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.
Réponses (1)
Nathan Hardenberg
le 27 Juil 2023
Modifié(e) : Nathan Hardenberg
le 27 Juil 2023
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--
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',[])
0 commentaires
Voir également
Catégories
En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!