Function: crop - restrict a plot to a box

Calling sequence:

crop(P,[a..b,c..d],x);
crop(P,[a..b,c..d,e..f],x);

Parameters:

P - a two- or three-dimensional plot structure

a, b, c, d, e, f - real constants (possibly infinite)

x - (optional) anything

Description:

Examples:

Two plots, and their combination using display .

> A:= plot(x,x=0..1,colour=red):
B:= plot(1-x,x=0..1,colour=blue):
plots[display]([A,B],scaling=constrained);

[Maple Plot]

The view option works on each individually, but not with the combination: it uses the largest rectangle containing both of the view rectangles, which in this case contains more of the red line than we ask for.

> Av:= plot(x,x=0..1,colour=red,view=[0..0.5,0..0.5]):
Bv:=plot(1-x,x=0..1,colour=blue,view=[0.2..0.8,0.2..0.8]):
plots[display]([Av,Bv],scaling=constrained);

[Maple Plot]

Combining plots together with the use of crop .

> Ac:= crop(A,[0..0.5,0..0.5]):
Bc:= crop(B,[0.2 .. 0.8, 0.2 .. 0.8]):
plots[display]([Ac,Bc],scaling=constrained);

[Maple Plot]

An example with a line segment, points, text and a polygon.

> P:= plots[display]({plot([[0,0],[10,10]],colour=red),
plots[pointplot]({seq([i,i+1],i=0..10)},colour=black,symbol=box), plots[polygonplot]([seq([i,(i-5)^2/2],i=0..10)],colour=cyan),
plots[textplot]({seq([i,i-1,convert(i,string)],i=0..10)},colour=blue)}): P;

[Maple Plot]

> crop(P,[1 .. 5,3 .. 5]);

[Maple Plot]

Using the optional third argument to ensure the whole box is in the plot:

> crop(P,[1..5,3..5],true);

[Maple Plot]

A three-dimensional example:

> Q:= plots[display]({
plots[spacecurve]([[0,0,-3],[0,0,3]],colour=green),
plots[tubeplot]([2*cos(t),2*sin(t),0],t=0..2*Pi,radius=1),
plots[pointplot3d]([seq([2*cos(j*Pi/5),2*sin(j*Pi/5),2],j=0..9)],symbol=box,symbolsize=15,colour=blue),
plots[textplot3d]({seq([2*cos(j*Pi/5),2*sin(j*Pi/5),3,convert([65+j],bytes)],j=0..9)},colour=red)
},scaling=constrained): Q; crop(Q,[0..3,-3..3,0..infinity]);

[Maple Plot]

[Maple Plot]

Ragged edges caused by removing surface elements.

> crop(Q,[-1.5..3,-3..3,-1..1]);

[Maple Plot]

See also: display , plot[options] , plot[structure] , plots , View option in arrays of plots

Maple Advisor Database R. Israel, 2000