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

조회 수: 11 (최근 30일)
faran
faran 2018년 6월 28일
편집: Geoff Hayes 2018년 6월 28일
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에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by