Advanced Graphics for InstructorsBy Mike May, S.J. - maymk@slu.eduOverview:When constructing graphics we start with the simple commands plot and plot3d that are immediately available when you open Maple. The second step is to learn tricks and options with those commands.A third step is to add in the display and display3d commands from the plots package. This lets you put several graphs together in the same display. The fourth step is to add in other commands from the plots and plottools packages.Basic PlottingBasic plotting uses the plot and plot3d commands to graph functions in Cartesian coordinates.plot(x^2-x,x=-3..3);
plot3d(x^2+y^3, x=-3..3, y=-2..2);The plot commands take as input the functions, the domains, and simple options. My list of options to start with include range, color, and axes. These were covered in the Plotting with Maple worksheet.plot(x^2-x,x=-3..3, y=-2..4, axes=normal);
plot3d(x^2+y^3, x=-3..3, y=-2..2, view=-4..10, color=red, axes=boxed);One also wants to be able to do parametric plots.plot([2*sin(2*t), 3*cos(3*t), t=0..2*Pi], color=blue);
plot3d([(3+cos(t))*sin(u), (3+cos(t))*cos(u), sin(t)],
u=0..2*Pi, t=0..2*Pi, color=green, scaling=constrained, axes=boxed);Getting help with basic plottingThe next level of control over plotting uses more options. The old fashioned way to do this is to use the help menu, select "Maple Help" and search for "plot, options", or "plot". One can also invoke help with a question mark from an input prompt, followed by the command of interest.?plotA second way is to pay attention to examples and copy, paste, and modify.One way to do this is with the plotbuilder tool.Look under the Tools menu, Assistants sub-menu, Plot Builder item. Walk through the construction, giving an expression to plot, a type of plot, and any option you are interested in. At the last minute, choose command rather than plot. This lets you see the command that does all the options you have chosen.In the example below we chose Plot builder and added expressions sin(x) + cos(y) + x +1 and 1. We then chose a 3d plot and selected options, making lots of choices to see what happens. Finally we chose command to print the command. The result can be copied and pasted into a new input prompt.(plots[display])(plot3d(sin(x)+cos(y)+x+1, x = -3 .. 3, y = -2 .. 4, style = PATCHCONTOUR, color = plum, shading = Z, axesfont = ([TIMES, ROMAN, 18]), title = "Some Graphs", titlefont = ([HELVETICA, BOLDOBLIQUE, 24]), orientation = ([40, 60])), plot3d(1, x = -3 .. 3, y = -2 .. 4, axesfont = ([TIMES, ROMAN, 18]), title = "Some Graphs", titlefont = ([HELVETICA, BOLDOBLIQUE, 24]), orientation = ([40, 60])))plots[interactive]();LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYpLUkjbWlHRiQ2KVEmcGxvdHNGJy8lJ2ZhbWlseUdRMFRpbWVzfk5ld35Sb21hbkYnLyUlYm9sZEdRJmZhbHNlRicvJSdpdGFsaWNHUSV0cnVlRicvJStmb3JlZ3JvdW5kR1EoWzAsMCwwXUYnLyUrZXhlY3V0YWJsZUdGNC8lLG1hdGh2YXJpYW50R1EnaXRhbGljRictSSNtb0dGJDYxUSJbRidGL0YyRjhGOy9GPlEnbm9ybWFsRicvJSZmZW5jZUdGNy8lKnNlcGFyYXRvckdGNC8lKXN0cmV0Y2h5R0Y3LyUqc3ltbWV0cmljR0Y0LyUobGFyZ2VvcEdGNC8lLm1vdmFibGVsaW1pdHNHRjQvJSdhY2NlbnRHRjQvJSdsc3BhY2VHUSwwLjE2NjY2NjdlbUYnLyUncnNwYWNlR0ZWLUYsNilRLGludGVyYWN0aXZlRidGL0YyRjVGOEY7Rj0tRkE2MVEiXUYnRi9GMkY4RjtGREZGRkhGSkZMRk5GUEZSRlQvRlhRLDAuMTExMTExMWVtRictRkE2MVEiKEYnRi9GMkY4RjtGREZGRkhGSkZMRk5GUEZSRlRGVy1GQTYxUSIpRidGL0YyRjhGO0ZERkZGSEZKRkxGTkZQRlJGVEZXLUZBNjFRIjtGJ0YvRjJGOEY7RkQvRkdGNC9GSUY3L0ZLRjRGTEZORlBGUi9GVVEmMC4wZW1GJy9GWFEsMC4yNzc3Nzc4ZW1GJw==(plots[display])(plot3d(sin(x)+cos(y)+x+1, x = -3 .. 3, y = -2 .. 4, style = PATCHCONTOUR, color = plum, shading = Z, axes = boxed, axesfont = ([TIMES, ROMAN, 16]), title = "Some Plots", titlefont = ([HELVETICA, BOLD, 24]), transparency = .2, orientation = ([30, 60])), plot3d(1, x = -3 .. 3, y = -2 .. 4, axes = boxed, axesfont = ([TIMES, ROMAN, 16]), title = "Some Plots", titlefont = ([HELVETICA, BOLD, 24]), orientation = ([30, 60])));LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYpLUkjbWlHRiQ2KVEmcGxvdHNGJy8lJ2ZhbWlseUdRMFRpbWVzfk5ld35Sb21hbkYnLyUlYm9sZEdRJmZhbHNlRicvJSdpdGFsaWNHUSV0cnVlRicvJStmb3JlZ3JvdW5kR1EoWzAsMCwwXUYnLyUrZXhlY3V0YWJsZUdGNC8lLG1hdGh2YXJpYW50R1EnaXRhbGljRictSSNtb0dGJDYxUSJbRidGL0YyRjhGOy9GPlEnbm9ybWFsRicvJSZmZW5jZUdGNy8lKnNlcGFyYXRvckdGNC8lKXN0cmV0Y2h5R0Y3LyUqc3ltbWV0cmljR0Y0LyUobGFyZ2VvcEdGNC8lLm1vdmFibGVsaW1pdHNHRjQvJSdhY2NlbnRHRjQvJSdsc3BhY2VHUSwwLjE2NjY2NjdlbUYnLyUncnNwYWNlR0ZWLUYsNilRLGludGVyYWN0aXZlRidGL0YyRjVGOEY7Rj0tRkE2MVEiXUYnRi9GMkY4RjtGREZGRkhGSkZMRk5GUEZSRlQvRlhRLDAuMTExMTExMWVtRictRkE2MVEiKEYnRi9GMkY4RjtGREZGRkhGSkZMRk5GUEZSRlRGVy1GQTYxUSIpRidGL0YyRjhGO0ZERkZGSEZKRkxGTkZQRlJGVEZXLUZBNjFRIjtGJ0YvRjJGOEY7RkQvRkdGNC9GSUY3L0ZLRjRGTEZORlBGUi9GVVEmMC4wZW1GJy9GWFEsMC4yNzc3Nzc4ZW1GJw==The commands display and display3dThe next commands to learn about are the display and display3d commands from the plots package.with(plots):We have already seen a number of uses of these commands:1) We can put together elements with different options.paramplot := plot([sin(2*x), cos(3*x), x=0..2*Pi], color=red):
curveplot := plot(x^2-2, x=-2..2, color=blue):
display({paramplot, curveplot}, axes=normal);2) We can put together elements from different kinds of plot structures:curve1 := plot(x^3-3*x, x=-2..2, color=blue):
extremepoints := pointplot([[1,-2], [-1,2]],
color=[green,red], symbol=diamond, symbolsize=20):
text1 := textplot([-1,2,"a local max"], color=red,
align={ABOVE}):
text2 := textplot([1,-2,"a local min"], color=green,
align={BELOW}):
display({curve1, extremepoints, text1, text2});3) We can make animationsJSFHf := x -> sin(x):
framer := proc(f,x,x0)
local fx0, slope;
fx0 := eval(f(x),x=x0);
slope := eval(diff(f(x),x), x=x0):
plot({f(x), slope*(x-x0)+fx0}, x=0..10, y=-3..3);
end proc:
framer(f,x,6);display([seq(framer(f,x,counter), counter=0..10)],
insequence=true);More kinds of plots than you can imaginePlotting with Maple is a deep subject. I favor the "just enough knowledge" approach to do the task at hand. It is however useful to see some of the places where you might find more commands. These commands are parts of packages that must be loaded to be used. In worksheets you have seen their use indicated by the with command in the first line.The plots and plottools packagesThere are, of course, the plots and plottools packages.with(plots);
with(plottools);From the plots package I have used:animate, arrow, contourplot, contourplot3d, display, display3d, fieldplot, fieldplot3d, gradplot, gradplot3d, implicitplot, implicitplot3d, pointplot, pointplot3d, spacecurve, textplot, and textplot3d.As a rule of thumb, the plots package has commands for kinds of plots and the plottools has commands for special kinds of objects. The distinction is not clean. Note that each has an arrow command, with the commands being slightly different from each other.Commands in a package can also be called with a long name. Thus plots[display] is available even if we have not loaded the plots package.Visualization in the Student packageThere are also graphical commands in other packages:with(Student[Calculus1]);
with(Student[MultivariateCalculus]);Some examples are in order:MeanValueTheorem(x^3 - x, x=-3..2, output = plot);RiemannSum(tan(x) - 2*x, x=-1..1, method = midpoint, output = plot, partition = 10);FunctionChart(sin(x) + x/2, slope=[thickness(2, 1), linestyle(solid, dash)], pointoptions=[symbolsize=20]);CrossSection(x^2+y^2+z^2 = 4, x+y= [1.9, 1.71.1,0.1, -1], x=-2..2, y=-2..2 , z=-2..2, title="Sphere");LagrangeMultipliers(x*y,[x^2/8+y^2/2-1],[x,y],output=plot);
LagrangeMultipliers(x*y,[x^2/8+y^2/2-1],[x,y],output=detailed);
LagrangeMultipliers(x*y,[x^2/8+y^2/2-1],[x,y]);
ApproximateInt(x^2+y^2,x=-4..4,y=-6..6, output = animation, partition = [12,12], frames=2..12);with(Student[VectorCalculus]);TNBFrame( <cos(t),sin(t),t/(2*Pi)>, output=animation, frames=15, scaling=constrained, axes=boxed, range=0..8*Pi );JSFH