# How to plot two histogram in one figure with different start point?

7 views (last 30 days)
faran on 28 Jun 2018
Edited: Geoff Hayes on 28 Jun 2018
Hi, I want to plot two histogram in one figure but I want them to not overlap on each other and come beside each other. I mean one histogram start from 0 to 1 and the other one start from 1 to 0 in the x axis. I used the code below for it but it is not working!! I want the histogram to have 100 bin and the edge be between 0.01 to 1. The code below will will plot two histogram on each other from 0.01 to 1. How can I have to histogram beside each other?
edges1=[0.01 0.01:0.01:1 1];
figure,
h = histogram(img1,edges1);xlim([0 2]);
hold on
h = histogram(img2,edges1);xlim([0 2]);

Geoff Hayes on 28 Jun 2018
Edited: Geoff Hayes on 28 Jun 2018
Sara - have you considered perhaps subtracting your second data set from one so that it's histogram is reveresed? (Which is I think what you want when you say and the other one start from 1 to 0 in the x axis. For example,
h = histogram(1 - img2,edges1);xlim([0 2]);
It might produce something similar to what you want...though I suspect will place some of the data in incorrect bins. The shape might still be preserved though...
(I'm assuming your data from img2 is in the interval [0,1].)