Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
Amit Ifrach
Amit Ifrach am 16 Aug. 2023
Beantwortet: Vedant am 8 Sep. 2023
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:
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'};
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:
  1 Kommentar
Dyuman Joshi
Dyuman Joshi am 16 Aug. 2023
"I want it to look as close as possibly to this histogram without the last bin:"
You can change the xlimits.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Vedant am 8 Sep. 2023
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.
% 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.
% 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:
Vedant Panchal

Community Treasure Hunt

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

Start Hunting!

Translated by