Merge several histogras into a one single plot

13 views (last 30 days)
I'm having multiple histograms of several images. I need to merege them in to a one histogram plot. I have tried so many ways and there it didn't work. It will be greatful if anyone can give me a possible way to do this.

Answers (1)

mizuki
mizuki on 22 Sep 2016
You can get histogram plot information by gca (get current axis) of gcf (get current figure). Under Axis properties, Histogram properties are stored.
% make two sample set
x1 = randn(100,1);
x2 = randn(100,1);
% draw the first histogram
figure(1)
histogram(x1);
h_f1 = gca; % get axis properties
d1 = h_f1.Children.Data; % get Data properties under Histogram property set
% draw the second histogram
figure(2)
histogram(x2);
h_f2 = gca;
d2 = h_f2.Children.Data;
figure(3)
histogram([d1 d2])
I am not sure if this is exactly what you wanted. For the next time, write what you have exactly tried so that others can figure out the problem instantly as well as you can get good answers.

Community Treasure Hunt

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

Start Hunting!