xregion yregion back/front control
I play with the new xregion command (R2023A)
The red region is hide by the histogram, not sure why it is not as document example and what should I do to bring it in front
Data = randn(1,1000);
figure
histogram(Data,20,’Normalization’,’pdf’,’FaceColor’, ‘c’);
hold on
m = mean(Data);
s = std(Data);
x = linspace(m-3*s,m+3*s).’;
g = 1/(s*sqrt(2*pi))*exp(-(x-m).^2/(2*s^2));
plot(x,g,’c’, ‘LineWidth’, 2);
xregion(1, m+3*s,’FaceColor’, [0.5 0 0], ‘FaceAlpha’, 1)
set(gca, ‘XTick’, [], ‘YTick’, [], ‘ZTick’, [], ‘Color’, ‘k’);
Note: I play with gca Children order, it doesn’t seem to affect the front/back priority.
Ultimately what I want is this (here I use patch rather than xregion)I play with the new xregion command (R2023A)
The red region is hide by the histogram, not sure why it is not as document example and what should I do to bring it in front
Data = randn(1,1000);
figure
histogram(Data,20,’Normalization’,’pdf’,’FaceColor’, ‘c’);
hold on
m = mean(Data);
s = std(Data);
x = linspace(m-3*s,m+3*s).’;
g = 1/(s*sqrt(2*pi))*exp(-(x-m).^2/(2*s^2));
plot(x,g,’c’, ‘LineWidth’, 2);
xregion(1, m+3*s,’FaceColor’, [0.5 0 0], ‘FaceAlpha’, 1)
set(gca, ‘XTick’, [], ‘YTick’, [], ‘ZTick’, [], ‘Color’, ‘k’);
Note: I play with gca Children order, it doesn’t seem to affect the front/back priority.
Ultimately what I want is this (here I use patch rather than xregion) I play with the new xregion command (R2023A)
The red region is hide by the histogram, not sure why it is not as document example and what should I do to bring it in front
Data = randn(1,1000);
figure
histogram(Data,20,’Normalization’,’pdf’,’FaceColor’, ‘c’);
hold on
m = mean(Data);
s = std(Data);
x = linspace(m-3*s,m+3*s).’;
g = 1/(s*sqrt(2*pi))*exp(-(x-m).^2/(2*s^2));
plot(x,g,’c’, ‘LineWidth’, 2);
xregion(1, m+3*s,’FaceColor’, [0.5 0 0], ‘FaceAlpha’, 1)
set(gca, ‘XTick’, [], ‘YTick’, [], ‘ZTick’, [], ‘Color’, ‘k’);
Note: I play with gca Children order, it doesn’t seem to affect the front/back priority.
Ultimately what I want is this (here I use patch rather than xregion) xregion, yregion, front, back MATLAB Answers — New Questions