changing scale of x-axis in histfit

Hi!
I am generating some histograms with a normal distribution using histfit, and I need to change the scale in the x-axis. Specifically, I get 3 histograms for three different possible outcomes, and I need the scale on all of them to be the same in the x-axis.
Thanks!

1 Comment

More simply, I just want to choose the scale in the x-axis for a histogram generated using histfit

Sign in to comment.

 Accepted Answer

I am not certain what you’re doing, but I would consider using the hold function.
For example:
D1 = randn(1,100); % Create Data For Distributions
D2 = 2+1.5*randn(1,100);
D3 = 3+0.5*randn(1,100);
figure(1) % Plot All ‘histift’s On The Same Axes
histfit(D1)
hold on
histfit(D2)
histfit(D3)
hold off
grid
Is this what you want to do?

4 Comments

not exactly, I want 3 separate histograms, and what I need to do is change the scale of the x-axis in each of them to make them the same. That is, I need a way to choose the scale in each case.
OK. I misunderstood. It’s just as easy though, all you need do is to set the 'XLim' property to be the same in each plot:
D1 = randn(1,100); % Create Data For Distributions
D2 = 2+1.5*randn(1,100);
D3 = 3+0.5*randn(1,100);
figure(1) % Plot All ‘histift’s On The Same Axes
histfit(D1)
set(gca, 'XLim', [-4 8])
grid
figure(2)
histfit(D2)
set(gca, 'XLim', [-4 8])
grid
figure(3)
histfit(D3)
set(gca, 'XLim', [-4 8])
grid
Did I get it correct this time?
yes, thank you!!
My pleasure!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!