Plot multiple functions - Maple Help

Home : Support : Online Help : Getting Started : How Do I... : Plot multiple functions

How Do I

 Plot Multiple Functions?

Using Commands

Plotting Lists of Expressions

The following examples with the plot command provide a list of expressions to plot.

Note: In Maple, a list is denoted using [ ] square brackets.

Example: Plotting Sine and Cosine on Same Plot



Step

Description

Illustration

1

Type the following:

plot([sin, cos])

$\mathrm{plot}\left(\left[\mathrm{sin},\mathrm{cos}\right]\right)$

2





Example: Plotting $x,{x}^{2}$ with Custom Color

Step

Description

Illustration

1

Type the following:

plot([x,x^2],x=0..2,color=["DarkViolet","Red"])

$\mathrm{plot}\left(\left[x,{x}^{2}\right],x=0..2,\mathrm{color}=\left["DarkViolet","Red"\right]\right)$

2

Press Enter.



Example: Plotting a Sequence



Step

Description

Illustration

1

Type the following:

plot([seq(BesselJ(n,x),n=1..4)],x=0..2*Pi,filled)

$\mathrm{plot}\left(\left[\mathrm{seq}\left(\mathrm{BesselJ}\left(n,x\right),n=1..4\right)\right],x=0..2\cdot \mathrm{Pi},\mathrm{filled}\right)$





2

Press Enter.



Example: Plotting Multiple 3-D Plots

This also works for 3-D plots:



Step

Description

Illustration

1

Type the following:

plot3d([x,sin(x)*y], x=-2*Pi..2*Pi, y=-5..5)





2

Press Enter.



Plotting Multiple Plot Structures

You can also combine multiple plot structures and display these together using the plots:-display command:

Example: Plotting Multiple Plot Structures Together

Step

Description

Illustration

1

Type the following: plot1:= plot(sin):

Then, press Enter.

$\mathrm{plot1}≔\mathrm{plot}\left(\mathrm{sin}\right):$



2

Type the following:

plot2 := plot(cos, color="Niagara Green"):

Then, press Enter.

$\mathrm{plot2}≔\mathrm{plot}\left(\mathrm{cos},\mathrm{color}="Niagara Green"\right):$



3

Type the following:

plots:-display([plot1,plot2])

Then, press Enter.



Example: Plotting Multiple 3-D Plots

The plots:-display command also works on 3-D plots:

$\mathrm{plot3}≔\mathrm{plot3d}\left(\mathrm{sin}\left(x\right)\cdot y,x=-2\cdot \mathrm{Pi}..2\cdot \mathrm{Pi},y=-5..5\right):$

$\mathrm{plot4}≔\mathrm{plot3d}\left(\sqrt{y},x=-2\cdot \mathrm{Pi}..2\cdot \mathrm{Pi},y=-5..5\right):$

$\mathrm{plots}:-\mathrm{display}\left(\left[\mathrm{plot3},\mathrm{plot4}\right]\right)$

Using Plot Builder

You can use the Plot Builder from the Context Panel to plot a list or sequence of expressions.

Here is the first from the previous section.

Example: Using Plot Builder to Plot Two Expressions

 Step Description Illustration 1 Type the following, and from the Context Panel, select Plot Builder:   sin(x),cos(x) $\mathrm{sin}\left(x\right),\mathrm{cos}\left(x\right)$ 2 The plot is shown in the main window, and in the Plot Builder window you can change options.   If you select Show Command in the right panel, you can see the underlying command used to create this plot.  (It's plots:-display.)

Drag and Drop

You can also combine multiple plots using drag and drop.

Example: Combining the Plots for $\mathrm{sin}\left(x\right)$ and $\mathrm{sin}\left(\frac{x}{2}\right)$

 Step Description Illustration 1 Type the following: sin(x)   Press Enter.   Click sin(x) and, from the context panel, choose Plots > 2-D Plot. $\mathrm{sin}\left(x\right)$$\to$  2 Type the following:  sin(x/2)   3 Drag the expression $\mathrm{sin}\left(\frac{x}{2}\right)$ onto the existing plot of $\mathrm{sin}\left(x\right)$. 

 Related Topics The How Do I... topics cover the essentials for doing mathematics in Maple. Learn more about available tools and features, such as palettes and the context panel. Refer to Help>Quick Reference for basic Getting Started tips.