Section 3: G raphing
In this section you will learn how to plot the graph of a function defined by an expression. Other topics covered include: combining the graphs of several expressions into a single plot, plotting points, and combining different plot structures into a single picture.
Plotting an Expression: the plot command
Example 1
We use the plot command to plot the graph of for x between - 5 and 5 .
Notice that Maple scales the y -axis automatically, choosing a y -scale that shows the entire graph corresponding to the specified domain.
You can override automatic y -scaling by specifying a range for y as well as x . On the next line we have limited the y -range to the interval [-20,40].
If you click on a graph with the left mouse button, the graph is selected and the bottom toolbar options are changed. See the reference diagram below. Now when you click on the graph, the point coordinates of its location are shown. The 1:1 button makes the x -scale and y -scale equal.
Scroll back up to the previous graph and experiment with these features. Try the other graph options as well.
Example 2
Automatic scaling is a useful feature but there are times when you may want to set the y range manually. For example automatic scaling isn't appropriate for graphs with vertical asymptotes.
Compare the next two graphs.
Notice how we have set the limits for y to the interval [-20,20] in the following plot command.
Example 3
Plot the graph of over the domain [-8, 8]. Choose a y -range that allows you to see the four x -intercepts.
First let's take a look at the plot with automatic scaling of y .
The large negative values for y near 8 have forced the vertical scale to be too large to see the x -intercepts clearly.
A better view is achieved by setting limits on the y -range.
Exercise 3.1
Plot over two complete periods.
Student Workspace 3.1
Answer 3.1
or
Exercise 3.2
Plot over the domain [-10,10] with automatic y -scaling.
After observing the graph, edit the domain and range so that you can see the x -intercepts clearly. Estimate the x -intercepts with the mouse cursor.
Student Workspace 3.2
Answer 3.2
Notice how large y becomes when x = -10 or x = 10; with automatic y scaling it is difficult to see how the function behaves for x between -2 and 2. In the next plot we restrict the y -scale in order to focus on the behavior for small y .
The x -intercepts are about -1.4, 1.4 and 0.
Plotting Several Expressions
To show more than one graph in the same picture list them in square brackets [ ] separated by commas.
Notice that each of the graphs is displayed using a different color. You can specify the colors for each function by adding a color option at the end of the command. The colors are assigned in the same order as the functions. Note that the colors must also be listed in a square bracket [ ] . Here is an example.
Here are the colors available in Maple.
aquamarine black blue navy coral cyan brown gold green gray grey khaki magenta maroon orange pink plum red sienna tan turquoise violet wheat white yellow
Exercise 3.3
Graph the functions and together. Experiment with different y ranges so that complete pictures of both graphs are shown.
Student Workspace 3.3
Answer 3.3
Plotting points
The plot command can also plot one or more points.
Plot the point (2, 3) . Note in the following line that we use two sets of square brackets.
We can control the size of the x- and y- ranges shown by adding these to the command as in the next line.
To graph more than one point list them in the plot command. Note the commas. Remember square brackets for each point and an extra pair of square brackets surround the list.
Example 4
Changing style to "line" connects the points in the order listed.
Example 5
Optional extensions can be used to specify point color and symbol (e.g. diamond, circle, cross is default) to indicate the points.
Exercise 3.4
Plot the following points using the color red and the diamond symbol: [1, 4] , [-2, -3], [4, -5] and [-6, 5] .
Then connect the points with lines in a separate plot command.
Student Workspace 3.4
Answer 3.4
Combining Graphs of Expressions and Points: the display command
A special plotting package called plots contains many additional graphing features. To use these commands, you need to execute the following line which loads plots . Recall, the colon at the end of the statement allows this line to be executed without displaying any distracting output. To see the contents of plots you can change the colon to a semicolon.
Warning, the name changecoords has been redefined
The display command allows you to combine graphs of expressions and points in the same picture. The first step is to name the individual picture components.
IMPORTANT: Be sure to use a colon at the end of the line to suppress output (see first three lines below). The display command is then used to do the actual plot (this ends with a semicolon).
Alternatively we can list these three related plot commands in a single execution group by typing [Shift] + [Enter] at end of each line.
For more on this see " Execution groups with more than one command" in the section Notes on the Maple Worksheet Interface at the end of this tutorial.
Exercise 3.5
Display a graph that contains both the function and its x- and y- intercepts, marked with circles.
Student Workspace 3.5
Answer 3.5
Interactive Graphing
In this section, you will see that Maple has tools you can use to plot graphs. Using smartplots or interactive tools, you can plot easily without having to specify details in the plot command.
Using smartplot command
The smartplot command generates an initial plot which can be further tailored through use of interactive controls.
Here is an example. To plot , type and execute:
By right-clicking on the graph, you can now adjust the details as you want.
For example, to change the domain to -4..4, right-click anywhere on the graph.
Select Axes then Range. The Axes Ranges window will pop up.
Under X, select the second option to customize the values and replace -10.4 with -4 and 10.4 with 4. Click OK, and the graph will update itself automatically.
Other changes can be made in very similar ways. Try and change the line and axes styles.
Another useful feature of the smartplot is drag-and-drop plotting.
Suppose a first smartplot (of ) has been generated. Then, execute
Select the blue output of this command then drag it and drop it onto the smartplot of . A graph of will apprear in the smartplot .
The smartplot can also be launched interactively, via the context-sensitive menu. Enter and execute
Select all the blue output and right-click on it. The context-sensitive pop-up menu gives the option Plots which leads to 2-D Plot, which, if selected, launches a smartplot of .
Using the interactive command
The interactive command is part of the plots package. It allows you to build plots interactively by opening a window where you can specify details.
For example, to graph using the interactive command, type and execute:
Initializing Java runtime environment.
Select 2-D Plot and click Next.
This will open the 2-D Plot window. After entering in your preferences, click Plot. This will display the graph of .
Try different options for line style, axes, or color as well.
The interactive plot builder can also be launched interactively, by typing and entering
then selecting, and right-clicking on the blue output. Choose Plots and Plot Builder from the pop-up context-sensitive menu, and the interactive plot-builder will launch.