irh
irh

Reputation: 358

How to draw a transparent circle in matlab?

To be clear, I don't want a transparent disk, but a circle drawn with a transparent marker. Is there a simple way to do it? None of the circle drawing primitives (rectangle and viscircles) seem to support ahlpa properties. I have considered using a scatter plot, but the sizes of those circles are set in points squared, which I am not sure I am willing to deal with (as opposed to simply setting the radius of the circle).

Upvotes: 0

Views: 1972

Answers (1)

Jimbo
Jimbo

Reputation: 3284

Most colors in Matlab support a fourth input value which is transparency with values between 0 and 1 where:

  • 0: fully transparent
  • 1: fully opaque (default)

Here's some example code with opaque red circle with semi-transparent green circle on top.

h1 = rectangle('Position',[1 2 5 6],'Curvature',[1,1]); %1,1, gives circle
h1.FaceColor = 'r';

h2 = rectangle('Position',[2 3 6 7],'Curvature',[1,1]);
h2.FaceColor = [0 1 0 0.2]; %mostly transparent green [R G B alpha]

enter image description here

Upvotes: 1

Related Questions