color nonoverlapping or overlapping region of two histograms

6 visualizzazioni (ultimi 30 giorni)
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 Commenti
Eirik Kvernevik
Eirik Kvernevik il 13 Nov 2021
Modificato: the cyclist il 13 Nov 2021
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)];

Accedi per commentare.

Risposte (0)

Prodotti


Release

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by