I have used imagesc
in MatLab to plot an acoustic field. I now want to overlay a semi-transparent filled in rectangle at a certain location on the image. Ideally I'd like to be able to do something like the following:
imagesc(g,g,field);
hold on
plotRectangle([100,100,200,200], 'b', 0.5)
hold off
where b is the color of the rectangle 0.5 is the transparency. Can this be done?
You can use rectangle
to create a rectangle object and then use a color specified as RGBA to include transparency
rectangle('Position', [100 100 200 200], 'FaceColor', [0 0 1 0.5])
Alternately, you can just use a patch
object
p = patch('vertices', [100, 100; 100, 200; 200, 200; 200 100], ...
'faces', [1, 2, 3, 4], ...
'FaceColor', 'b', ...
'FaceAlpha', 0.5)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With