I want to adjust the x-axis according to the histogram distribution.

1 view (last 30 days)
A simple example is shown in the following image.
It does not mean histogram smoothing.

Answers (2)

Star Strider
Star Strider on 30 Sep 2018

I am not certain what you want to do.

Try this:

x = 0:50;                               % Create Data
y = exp(-0.1*x);                        % Create Data
mask = y >= 0.1;                        % Select Data Greater Than A Threshold Value
figure
subplot(2,1,1)
bar(x, y)
subplot(2,1,2)
bar(x(mask), y(mask))

It selects values for ‘y’ greater than a threshold value, then plots only those values in the second subplot. Note that you must use the bar plot for this, so you will need to use histcounts or related functions first.

  2 Comments
Star Strider
Star Strider on 30 Sep 2018
You can set the threshold to be anything you want. The value of the threshold and how you calculate it depends on your data.
For example, using histcounts (link):
x = 0:50; % Create Data
data = exp(-0.1*x); % Create Data
nbins = 30;
[N,edges] = histcounts(data,nbins); % Histogram
mask = N >= 0.1*max(N); % Define Conditions Based On Histogram Frequencies
ctrs = edges(1:end-1) + mean(diff(edges)); % Calculate Centres
figure
subplot(2,1,1)
bar(ctrs, N)
subplot(2,1,2)
bar(ctrs(mask), N(mask))
Without your data, I cannot be more specific.

Sign in to comment.


Image Analyst
Image Analyst on 30 Sep 2018

Maybe you want

xlim([0, 0.02]); % Make the x axis go from 0 to 0.02.

Categories

Find more on Data Distribution Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!