Histogram shows one value at the very end that ruins the plot
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello I have a vactor of values and I am ploting a histogram. I get one value at the very end that is ruining my plot. I cannot get rid of this. Can you please help.
My code is simple and is below. I have also attached data file RT160 in .mat format. Please help.
figure(1);
histogram(RT160,150);
xlabel('Cost (USD)');
ylabel('Counts');
1 comentario
HWIK
el 9 de Mzo. de 2022
If what you want is just to omit that value you can just change the x limits
Respuestas (1)
Steven Lord
el 9 de Mzo. de 2022
If that last bin is (roughly) twice as high as you think it should be, that's because the last bin includes both values that match its left bin edge and values that match its right bin edge. The rest of the bins include just their left bin edge (leaving their right bin edge to their neighbor to the right.)
x = randi(10, 1, 1e3);
figure
histogram(x, 1:10) % Last bin contains both 9 and 10
figure
histogram(x, 1:11) % Last bin is [10, 11] which matches only 10 in x
I'd just add one element at the end of my bin edges, the max of my data plus my desired BinWidth.
desiredBinWidth = 1;
newUpperLimit = max(x) + desiredBinWidth
0 comentarios
Ver también
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!