Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to Make Transparent Rectangles

Subject: How to Make Transparent Rectangles

From: omegayen

Date: 17 Dec, 2010 18:22:05

Message: 1 of 3

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.

Subject: How to Make Transparent Rectangles

From: Sean de

Date: 17 Dec, 2010 18:52:08

Message: 2 of 3

"omegayen " <omegayen@ameritech.net> wrote in message <ieg9od$8nc$1@fred.mathworks.com>...
> 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.

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

Subject: How to Make Transparent Rectangles

From: Walter Roberson

Date: 17 Dec, 2010 19:26:00

Message: 3 of 3

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.)

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us