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?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/191537/image.jpeg)
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]);
0 件のコメント
回答 (1 件)
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].)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Histograms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!