matlab美化圖片之添加背景顏色

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)在最上層的信息。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容