Thread Subject: Color Gradation

Subject: Color Gradation

From: Ken Fleisher

Date: 3 Jan, 2008 21:02:18

Message: 1 of 3

Is it possible to fill a polygon with a color gradation
between two or more colors instead of just a solid color?
From the docs, it doesn't appear to be possible. If it's not
a built in option, how might I go about this?

Thanks in advance.

Ken

Subject: Color Gradation

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 3 Jan, 2008 21:16:27

Message: 2 of 3

In article <fljigq$qf4$1@fred.mathworks.com>,
Ken Fleisher <k-fleisher.donotspamme@nga.gov> wrote:
>Is it possible to fill a polygon with a color gradation
>between two or more colors instead of just a solid color?
>From the docs, it doesn't appear to be possible. If it's not
>a built in option, how might I go about this?

Possibly if you use a patch() object for the polygon, and
specify the FaceColor as 'interp' ? See the documentation
on 'Patch Properties'.
--
  "There are some ideas so wrong that only a very intelligent person
  could believe in them." -- George Orwell

Subject: Color Gradation

From: Doug Schwarz

Date: 3 Jan, 2008 23:18:36

Message: 3 of 3

In article <fljigq$qf4$1@fred.mathworks.com>,
 "Ken Fleisher" <k-fleisher.donotspamme@nga.gov> wrote:

> Is it possible to fill a polygon with a color gradation
> between two or more colors instead of just a solid color?
> From the docs, it doesn't appear to be possible. If it's not
> a built in option, how might I go about this?
>
> Thanks in advance.
>
> Ken

Yes. This will create a patch with vertices at (0,0), (0,1) and (1,0)
and set the colors of those vertices to be red, green and blue
respectively with the colors in the middle being interpolated.

  x = [0;0;1]; % x-coordinates
  y = [0;1;0]; % y-coordinates
  rgb0 = [1 0 0;0 1 0;0 0 1]; % row 1 = red, row 2 = green, etc.
  rgb = permute(rgb0,[1 3 2]); % make into 3D array, plane 1 = red, etc.
  patch(x,y,rgb)

--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.

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
color gradation Ken Fleisher 3 Jan, 2008 16:04:58
polygon Ken Fleisher 3 Jan, 2008 16:04:58
rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com