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

4 次查看(过去 30 天)
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]);

回答(1 个)

Geoff Hayes
Geoff Hayes 2018-6-28
编辑:Geoff Hayes 2018-6-28
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].)

类别

Help CenterFile Exchange 中查找有关 Histograms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by