Thread Subject: legend patch alpha values

Subject: legend patch alpha values

From: Michael Ashby

Date: 19 Feb, 2010 17:52:02

Message: 1 of 2

Suppose I plot a transparent patch object as follows and add a legend:

x = [0 0;0 1;1 1];
y = [1 1;2 2;2 1];
patch(x,y,'k', 'FaceAlpha', 0.5)
legend('patch1')

My problem is that the patch in the legend entry does not have the same 'FaceAlpha' value as my plotted patch - it therefore appears as non-matching, darker color.
How can I control the legend entry to have a matching FaceAlpha?

Many thanks for any help,

Mike

Subject: legend patch alpha values

From: Walter Roberson

Date: 19 Feb, 2010 19:51:33

Message: 2 of 2

Michael Ashby wrote:
> Suppose I plot a transparent patch object as follows and add a legend:
>
> x = [0 0;0 1;1 1];
> y = [1 1;2 2;2 1];
> patch(x,y,'k', 'FaceAlpha', 0.5)
> legend('patch1')
>
> My problem is that the patch in the legend entry does not have the same
> 'FaceAlpha' value as my plotted patch - it therefore appears as
> non-matching, darker color. How can I control the legend entry to have a
> matching FaceAlpha?

Remember, FaceAlpha controls the blending of the colour with what-ever happens
to be underneath. As what is underneath the first patch is probably not the
same colour as what is underneath the legend, you are probably not going to be
able to match the legend patch colour to the figure patch colour, not unless
you use FaceAlpha of 1.

In any case, if you assign the output of legend() to a variable, it will be
the handle of the separate axis that the legend is drawn on. You can findobj()
from there to locate the patch within that axes, and set the properties of
that patch as you like.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
legend Michael Ashby 19 Feb, 2010 12:54:10
patch Michael Ashby 19 Feb, 2010 12:54:10
alpha Michael Ashby 19 Feb, 2010 12:54:10
rssFeed for this Thread

Contact us at files@mathworks.com