Function: colourize - change colours in a plot

Calling sequence:

colourize(P,f,s);

colourize(P,f,[c1,c2]);

Parameters:

P - a two or three-dimensional plot structure.

f - a function.

s - (optional) the colouring system: RGB, HSV or HUE.

c1, c2 - colour specifications

Description:

Examples:

A parametric spiral curve, colour varying from blue to red.

> colourize(plot([t*cos(t),t*sin(t),t=0..50],scaling=constrained),(x,y) -> sqrt(x^2+y^2)/50, [blue, red]);

A rectangular grid created with densityplot , showing a bug (which occurs when the grid option is given with unequal numbers). The colourized version is correct.

> P:= plots[densityplot](x/5,x=0..5,y=0..5,
grid=[7,8],colorstyle=HUE): P;
colourize(P,(x,y) -> x/5,HUE);

A three-dimensional plot.

> colourize(plot3d({x^2+y^2,2-x^2-y^2},
x=-1..1,y=-1..1, style=patch),
(x,y,z) -> [z/2,0,1-z/2],RGB);

Animation with points and text.

> with(plots):
P:= display([seq(display(
{ pointplot({seq([1.1*(cos(i*Pi/5)*(1-j/10)+
cos((i+3)*Pi/5)*j/10),1.1*(sin(i*Pi/5)*(1-j/10)+
sin((i+3)*Pi/5)*j/10)],
i=0..9)},symbol=BOX),
textplot({seq([cos(i*Pi/5+j*Pi/50),sin(i*Pi/5+j*Pi/50),j],i=0..9)})}),j=0..9)],insequence=true,axes=none,scaling=constrained):
colourize(P,(x,y) -> [(arctan(x,y)+Pi)/(2*Pi),1,sqrt(x^2+y^2)/1.1], HSV);