How to add spaces between bars on a histogram

29 visualizaciones (últimos 30 días)
Joseph Turner
Joseph Turner el 13 de Abr. de 2021
Editada: Adam Danz el 15 de Abr. de 2021
I have the following MATLAB code:
histogram(degree(G1),'Normalization','probability')
And I would like to add a space between each bar of the histogram, with x axis of the graph being integer numbers.

Respuesta aceptada

Adam Danz
Adam Danz el 14 de Abr. de 2021
> I would like to add a space between each bar of the histogram, with x axis of the graph being integer numbers.
Sounds like you're describing a bar plot rather than a histrogram. See histogram > Name-Value inputs > Normalization > probability to learn how to normalize the inputs for the bar inputs.
If you get stuck, show us where you're at and we can help you get unstuck. If a bar plot is not what yo're looking for, some additional details may be helpful.
  2 comentarios
Joseph Turner
Joseph Turner el 14 de Abr. de 2021
Editada: Joseph Turner el 14 de Abr. de 2021
Thanks a lot for your help. I meant similar to the image attached, where there is a space between each bar. I have tried using 'barWidth' but this will not work since my data is not categoric
Adam Danz
Adam Danz el 14 de Abr. de 2021
Editada: Adam Danz el 15 de Abr. de 2021
Yep, definitely want to use a bar plot and that does not require your data to be categorical. Why can't you use bar?

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst
Image Analyst el 15 de Abr. de 2021
Use histcounts(), which does not plot, rather than histogram (which does plot), and then use bar(counts, widthFraction) to plot
counts = histcounts(data);
bar(counts, 0.4); % Duty cycle of 40% for the bars gives a big space between the bars.
grid on;

Categorías

Más información sobre Data Distribution Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by