views:

39

answers:

1

I want to plot a 2d rect (using the rectangle function is good enough for my needs), but with a linearly interpolated color, i.e at the bottom it should be red, at the top blue, and between the two there should be the linear interpolation of the two colors. How can I do this?

+4  A: 

Patch is the answer. In fact, you can use it on any polygonal patch.

patch([0 0 1 1],[0 2 3 0],reshape([0 0 0;1 1 1;0 1 0;1 0 0],4,1,3))
woodchips