Is it possible to make a large range bin to take less area over X axis?

5 次查看(过去 30 天)
לק"י
Hello!
I ploted some data over a histogram. the edges vector is this:
edges=[0:0.1378:8.2668 61.8908];
And the plot commands are these:
figure(15)
histogram(acd3cd8onlyareas*pxl2nm, edges, 'Normalization', 'probability')
set(gca, 'yscale','log')
h.Facecolor=[0 0 1];
hold on
histogram(acd45cd8onlyareas*pxl2nm, edges, 'Normalization', 'probability')
h.Facecolor=[1 0 0];
TestL={'aCD3 - blue','aCD45 - red'};
hLg=legend(TestL,'Location','northeast');
ax = gca;
ax.XTick = [pxl2nm 150*pxl2nm 300*pxl2nm];
When I plot the figure i get a large bin that "squeezes" the first part of the histogram:
is it possible to make only the last bin to take less space? I want it to look as close as possibly to this histogram without the last bin:
Thanks,
Amit.

回答(1 个)

Vedant
Vedant 2023-9-8
If you are experiencing a large bin that "squeezes" the first part of the histogram when plotting a figure, it is likely due to the automatic binning algorithm used by the histogram function. The algorithm tries to determine the optimal number and width of bins based on the data range and distribution.
To address this issue and improve the visualization of your histogram, you can try the following approaches:
  • Specify the number of bins: Experiment with different bin numbers to find a value that provides a more balanced distribution and avoids the squeezing effect.
ThemeCopy
% Example specifying the number of bins
numBins = 20; % Adjust the number of bins as needed
histogram(data, numBins);
  • Adjust the bin width: Another option is to adjust the width of each bin to better capture the distribution of your data.
ThemeCopy
% Example specifying custom bin edges
binEdges = [0:0.5:10]; % Adjust the bin edges as needed
histogram(data, binEdges);
You may refer to histogram documentation from here:
Thanks,
Vedant Panchal

类别

Help CenterFile Exchange 中查找有关 Histograms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by