MATLAB: ConstantLine always on the top

constantlineMATLABuistack

I have been noticing that ConstantLine, which is plotted by xline() or yline() functions, always located on the top of other objects in an axes, no matter whether I plot the ConstantLine before or after other objects (e.g., Line, Scatter)
Even rearranging it by using uistack() like this did nothing:
uistack(ConsLine, 'bottom')
I have checked that all objects are the children of the axes, therefore, I should be able to rearrange it by uistack(), right?
I have also tried setting the HandleVisibility property to 'on' before uistack-ing, but nothing happened:
set(allchild(gca), 'HandleVisibility', 'on');
uistack(ConsLine, 'bottom')
I could not find anything on the documentation or here on MATLAB Answers regarding this behaviour.
Please help. I'm using MATLAB R2020b. Thank you so much.

Best Answer

It's undocumented but here's now to set the ConstantLine to the back of the uistack.
% Set up example
clf()
plot(magic(5),'LineWidth',5)
xh = xline(3,'LineWidth',8,'Alpha',1);
% Set ConstantLine to 'back'
% Temporarily disable the warning that appears when accessing
% the undocumented properties.
warnState = warning('off','MATLAB:structOnObject');
cleanupObj = onCleanup(@()warning(warnState));
Sxh = struct(xh); % Get undocumented properties (you'll get a warning)
clear('cleanupObj') % Trigger warning reset
Sxh.Edge.Layer = 'back'; % Set ConstantLine uistack