How to change space between bars in a bar graph and the y-axis/edges of the graph?

105 vues (au cours des 30 derniers jours)
I'm trying to change the distance between the bars of my graph and the vertical edges of the graph so there is little to no space (the bars touch the y-axis). How can I do this? My current code is:
data = [1, 2, 3; 1, 2, 3; 1, 2, 3];
labels = ["a", "b", "c"];
graph = bar(pubs,'stacked');
ylabel("Number of Publications");
xticks(1:length(data));
xticklabels(labels);
xtickangle(45);
set(gcf, 'Position', [0,0,1000,400]);

Réponse acceptée

Ameer Hamza
Ameer Hamza le 15 Juin 2020
data = [1, 2, 3; 1, 2, 3; 1, 2, 3];
labels = ["a", "b", "c"];
graph = bar(data,'stacked');
ylabel("Number of Publications");
xticks(1:length(data));
xticklabels(labels);
xtickangle(45);
set(gcf, 'Position', [0,0,1000,400]);
axis tight % <==== add this line
  1 commentaire
Siavash
Siavash le 5 Nov 2021
Two questions regarding this:
  1. Is it possible to only mage one of the axes tight (say x)?
  2. Is it possible to somehow apply this to string (categorical) x-axis too?
Thank you.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Distribution 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!

Translated by