
background.png
The image is generated by myself in matlab.
只是在產(chǎn)生的圖案中給想要標(biāo)注的地方添加背景顏色,同時要求背景顏色在線圖的下面,代碼如下:
figure
plot(YData)
grid on
xlabel('pixel position')
ylabel('grayscale value')
hold on
hg1 = line([434,434],[1,199]);
set(hg1, 'LineWidth',lineWidth,'Color',barColor)
hg2 = line([65,65],[1,199]);
set(hg2, 'LineWidth',lineWidth,'Color',barColor)
hg3 = line([782,782],[1,199]);
set(hg3, 'LineWidth',lineWidth,'Color',barColor)
hg4 = line([1098,1098],[1,199]);
set(hg4, 'LineWidth',lineWidth,'Color',barColor)
hg5 = line([1367,1367],[1,199]);
set(hg5, 'LineWidth',lineWidth,'Color',barColor)
hg6 = line([1574,1574],[1,199]);
set(hg6, 'LineWidth',lineWidth,'Color',barColor)
h = get(gca,'Children');
set(gca,'Children',[h(7),h(6),h(5),h(4),h(3),h(2),h(1)])

onTopOfFigure.png
This image is generated by myself in matlab.
這幅圖中想要產(chǎn)生的背景顏色改過了原先的線圖,并不是我想要的,其代碼與前面的區(qū)別主要如下:
set(gca,'Children',[h(1),h(6),h(5),h(4),h(3),h(2),h(7)])
只是調(diào)換了每個handle的順序,會導(dǎo)致最終的渲染次序顛倒,最終遮擋了想要出現(xiàn)在最上層的信息。