> 
contplot:=proc(ee, rng1, rng2)
local clabels, clegend, i, ncrvs, newP, otherdat, others, tcrvs, tempP;
(clegend,others):=selectremove(type,[_rest],identical(:legend)=anything);
(clabels,others):= selectremove(type,others,identical(:contourlabels)=anything);
if nops(clegend)>0 then
tempP:=:plots:contourplot(ee,rng1,rng2,others[],
':contourlabels'=rhs(clegend[1]));
tempP:=subsindets(tempP,'specfunc(:_HOVERCONTENT)',
u>`if`(has(u,"null"),NULL,':LEGEND'(op(u))));
if nops(clabels)>0 then
newP:=plots:contourplot(ee,rng1,rng2,others[],
':contourlabels'=rhs(clabels[1]));
tcrvs:=select(type,[op(tempP)],'specfunc(CURVES)');
(ncrvs,otherdat):=selectremove(type,[op(newP)],'specfunc(CURVES)');
return ':PLOT'(seq(':CURVES'(op(ncrvs[i]),op(indets(tcrvs[i],'specfunc(:LEGEND)'))),
i=1..nops(ncrvs)),
op(otherdat));
else
return tempP;
end if;
elif nops(clabels)>0 then
return plots:contourplot(ee,rng1,rng2,others[],
':contourlabels'=rhs(clabels[1]));
else
return plots:contourplot(ee,rng1,rng2,others[]);
end if;
end proc:

> 
contplot(x^2+y^2, x=2..2, y=2..2,
coloring=["Yellow","Blue"],
contours = 9,
size=[500,400],
legendstyle = [location = right],
legend=true,
contourlabels=true,
view=[2.1..2.1,2.1..2.1]
);

> 
contplot(x^2+y^2, x=2..2, y=2..2,
coloring=["Yellow","Blue"],
contours = 17,
size=[500,400],
legendstyle = [location = right],
legend=['contourvalue',$("null",7),'contourvalue',$("null",7),'contourvalue'],
contourlabels=true,
view=[2.1..2.1,2.1..2.1]
);

> 
# Apparently legend items must be unique, to persist on document reopen.
contplot(x^2+y^2, x=2..2, y=2..2,
coloring=["Yellow","Blue"],
contours = 11,
size=[500,400],
legendstyle = [location = right],
legend=['contourvalue',seq(cat($(` `,i)),i=2..5),
'contourvalue',seq(cat($(` `,i)),i=6..9),
'contourvalue'],
contourlabels=true,
view=[2.1..2.1,2.1..2.1]
);

> 
contplot(x^2+y^2, x=2..2, y=2..2,
coloring=["Green","Red"],
contours = 8,
size=[400,450],
legend=true,
contourlabels=true
);

> 
contplot(x^2+y^2, x=2..2, y=2..2,
coloring=["Yellow","Blue"],
contours = 13,
legend=['contourvalue',$("null",5),'contourvalue',$("null",5),'contourvalue'],
contourlabels=true
);

> 
(low,high,N):=0.1,7.6,23:
conts:=[seq(low..high*1.01, (highlow)/(N1))]:
contplot(x^2+y^2, x=2..2, y=2..2,
coloring=["Yellow","Blue"],
contours = conts,
legend=['contourvalue',$("null",floor((N3)/2)),'contourvalue',$("null",ceil((N3)/2)),'contourvalue'],
contourlabels=true
);

> 
plots:display(
subsindets(contplot((x^2+y^2)^(1/2), x=2..2, y=2..2,
coloring=["Yellow","Blue"],
contours = 7,
filledregions),
specfunc(CURVES),u>NULL),
contplot((x^2+y^2)^(1/2), x=2..2, y=2..2,
coloring=["Yellow","Blue"],
contours = 7, #grid=[50,50],
thickness=0,
legendstyle = [location=right],
legend=true),
size=[600,500],
view=[2.1..2.1,2.1..2.1]
);

> 
plots:display(
contplot(x^2+y^2, x=2..2, y=2..2,
coloring=["Yellow","Blue"],
contours = 5,
thickness=0, filledregions),
contplot(x^2+y^2, x=2..2, y=2..2,
coloring=["Yellow","Blue"],
contours = 5,
thickness=3,
legendstyle = [location=right],
legend=typeset("<=",contourvalue)),
size=[700,600],
view=[2.1..2.1,2.1..2.1]
);

> 
N:=11:
plots:display(
contplot(sin(x)*y, x=2*Pi..2*Pi, y=1..1,
coloring=["Yellow","Blue"],
contours = [seq(1+(i1)*(1(1))/(N1),i=1..N)],
thickness=3,
legendstyle = [location=right],
legend=true),
plots:densityplot(sin(x)*y, x=2*Pi..2*Pi, y=1..1,
colorscheme=["zgradient",["Yellow","Blue"],colorspace="RGB"],
grid=[100,100],
style=surface, restricttoranges),
plottools:line([2*Pi,1],[2*Pi,1],thickness=3,color=white),
plottools:line([2*Pi,1],[2*Pi,1],thickness=3,color=white),
plottools:line([2*Pi,1],[2*Pi,1],thickness=3,color=white),
plottools:line([2*Pi,1],[2*Pi,1],thickness=3,color=white),
size=[600,500]
);

> 
N:=13:
plots:display(
contplot(sin(x)*y, x=2*Pi..2*Pi, y=1..1,
coloring=["Yellow","Blue"],
contours = [seq(1+(i1)*(1(1))/(N1),i=1..N)],
thickness=6,
legendstyle = [location=right],
legend=['contourvalue',seq(cat($(` `,i)),i=2..3),
'contourvalue',seq(cat($(` `,i)),i=5..6),
'contourvalue',seq(cat($(` `,i)),i=8..9),
'contourvalue',seq(cat($(` `,i)),i=11..12),
'contourvalue']),
plots:densityplot(sin(x)*y, x=2*Pi..2*Pi, y=1..1,
colorscheme=["zgradient",["Yellow","Blue"],colorspace="RGB"],
grid=[100,100],
style=surface, restricttoranges),
plottools:line([2*Pi,1],[2*Pi,1],thickness=6,color=white),
plottools:line([2*Pi,1],[2*Pi,1],thickness=6,color=white),
plottools:line([2*Pi,1],[2*Pi,1],thickness=6,color=white),
plottools:line([2*Pi,1],[2*Pi,1],thickness=6,color=white),
size=[600,500]
);

