color nonoverlapping or overlapping region of two histograms

6 次查看(过去 30 天)
I want to color a nonoverlapping region of a figure displaying two histograms. That is I want to color the green-colored region displayed in the figure below.
An example of how to do this is much appreciated !
  3 个评论
Eirik Kvernevik
Eirik Kvernevik 2021-11-13
编辑:the cyclist 2021-11-13
I post a similar example with slightly different data :running this code you should get a region to the left of the orange/redish bar I would like to color:
Data1 = [0.6 0.7 0.9 0.85 0.94 0.96 0.90 0.70 0.66 0.80 0.4 0.88];
Data2 = [0.88 0.87 0.88 0.95 0.92 0.96 0.98 0.99 0.90 0.89 0.91 0.94];
h1 = histogram(Data1);
hold on
h2 = histogram(Data2);
ax = gca;
ax.XGrid = 'off';
ax.YGrid = 'on';
h1.Normalization = 'probability';
h2.Normalization = 'probability';
h1.DisplayStyle = 'stairs';
h2.DisplayStyle = 'stairs';
h1.NumBins = 5;
% h1.EdgeColor = [0.9290 0.6940 0.1250];
% h2.EdgeColor = [0.4940 0.1840 0.5560];
h1.EdgeColor = [0 0.4470 0.7410];
h2.EdgeColor = [0.8500 0.3250 0.0980];
h1.LineWidth = 2; h2.LineWidth = 2;
h2.BinLimits = [min(Data2 ) max(Data2)];
h1.BinLimits = [min(Data1) max(Data1)];

请先登录,再进行评论。

回答(0 个)

类别

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

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by