The image is generated by myself in matlab.
只是在产生的图案中给想要标注的地方添加背景颜色,同时要求背景颜色在线图的下面,代码如下:
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)])
This image is generated by myself in matlab.
这幅图中想要产生的背景颜色改过了原先的线图,并不是我想要的,其代码与前面的区别主要如下:
set(gca,'Children',[h(1),h(6),h(5),h(4),h(3),h(2),h(7)])
只是调换了每个handle的顺序,会导致最终的渲染次序颠倒,最终遮挡了想要出现在最上层的信息。