原文:http://blogs.mathworks.com/steve/2007/01/01/superimposing-line-plots/
To make sure the grid is visible over all pixel colors, I'll use the trick of superimposing two line objects with contrasting colors and line styles. The Pixel Region Tool in the Image Processing Toolbox uses this same trick.
M = size(rgb,1);
N = size(rgb,2);
for k = 1:25:M
x = [1 N];
y = [k k];
plot(x,y,'Color','w','LineStyle','-');
plot(x,y,'Color','k','LineStyle',':');
end
for k = 1:25:N
x = [k k];
y = [1 M];
plot(x,y,'Color','w','LineStyle','-');
plot(x,y,'Color','k','LineStyle',':');
end
hold off
即在每次先画一条白色的线,然后画一条黑色的虚线,这样看起来就是在同一位置上同时显示黑色和白色的虚线,颜色相反的线,因此,在图像上的任何地方都能看到。