Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to Make Transparent Rectangles

1,608 views
Skip to first unread message

omegayen

unread,
Dec 17, 2010, 1:22:05 PM12/17/10
to
I tried looking for solutions to this but am still at loss.

How do I make a rectangle semi-transparent?

I can draw a rectangle with

rectangle('Position',[0 3 1 1],'EdgeColor','blue','FaceColor',[0 0 0])

but rectangle does not have a FaceAlpha property

I see something about using annotation

but get an error when position values are outside of 1

annotation('rectangle',[0 3 1 1])
??? Error using ==> annotation at 130
position values must be between 0 and 1

so does anyone know how I can draw a semi transparent rectangle? thanks.

Sean de

unread,
Dec 17, 2010, 1:52:08 PM12/17/10
to
"omegayen " <omeg...@ameritech.net> wrote in message <ieg9od$8nc$1...@fred.mathworks.com>...

ANNOTATION uses a percentage of the figure size instead of coordinates.

For example:
figure;
annotation('rectangle',[.2 .4 .1 .1]);
% 20% across x, 40% across y, 10% width,10%height

-Sean

Walter Roberson

unread,
Dec 17, 2010, 2:26:00 PM12/17/10
to
On 10-12-17 12:22 PM, omegayen wrote:
> I tried looking for solutions to this but am still at loss.
>
> How do I make a rectangle semi-transparent?

You can't. Use a patch() instead. (In general, this may require calculating
the vertices of the approximation to the curve, if you specify curvature. The
example you gave is a straight-forward four-vertex patch.)

0 new messages