 plots - Maple Programming Help

plots

 shade the area or volume between two functions

Parameters

 f, g - expressions in the variable x f1, g1 - expressions in the variables x and y x, y - names a, b, c, d - real constants p, q - procedures or operators taking one argument p1,q1 - procedures or operators taking two arguments

Options

 • changefill : a list of plotting options to be applied to the filled region
 • negativeonly : show only regions where the difference of the first two arguments is negative; default is false
 • positiveonly : show only regions where the difference of the first two arguments is positive; default is false
 • showboundary : boolean indicating if the boundaries should be shown; default is true

Summary

 • The shadebetween command colors the area between two curves or two surfaces. The calling sequences are very similar to those of the plot and plot3d commands, except that you are providing two curves or surfaces instead of one. These can be given as expressions or procedures. Plotting options can be provided, including ones specifically for the filled region. The following example colors the area between $x$ and ${x}^{2}$ in blue.
 > with(plots): Description

 • The shadebetween command colors the area between two curves in a 2-D plot or the volume between two surfaces in a 3-D plot. Specifically, given functions $f\left(x\right)$ and $g\left(x\right)$, it colors the area where a point $u,v$ has a value $v$ between $f\left(u\right)$ and $g\left(u\right)$. In the 3-D case, given functions $f\left(x,y\right)$ and $g\left(x,y\right)$, it colors the area where a point $u,v,w$ has a value $w$ between $f\left(u,v\right)$ and $g\left(u,v\right)$.
 • In the first calling sequence, f and g are two expressions in the variable x, and the third argument has the type name=range. This calling sequence is similar to the one required for the plot command and produces a 2-D plot. The second calling sequence requires two expressions in variables x and y, along with two additional arguments of type name=range, and is similar to that for the plot3d command.
 • The third and fourth calling sequences are similar to the operator-form calling sequences for the plot and plot3d commands and produce 2-D and 3-D plots respectively. The parameters p and q must take one argument and return a numeric value, while the parameters p1 and q1 take two arguments and return a numeric value.
 • The positiveonly and negativeonly options allow you to plot only those regions where the difference of the first two arguments is either positive or negative respectively. These are set to false by default.
 • The showboundary option is set to true by default and causes the curves or surfaces as specified in the first two arguments to shadebetween to be displayed. If this option is set to false, then only the filled region is displayed.

Using Plotting Options

 • Additional plotting options, if applicable, may be given with any of the calling sequences. These are described in the plot/option and plot3d/option help pages. The coords option does not work with this command.
 • Options that you wish to have applied to the filled region only may be given in a list using the changefill option. For example, the following command displays the curves in blue but the filled region in orange.
 > shadebetween(x, x^2, x=0..2, color="Blue", thickness=3, changefill=[color="Orange"]); • The filled areas corresponding to the positive or negative parts can have different characteristics. This is done by  providing a suboption of the form optname=[value1, value2] within the changefill option.  For example, the following command colors the positive part orange and the negative part yellow.
 > shadebetween(x, x^2, x=0..2, color="Blue", thickness=3, changefill=[color=["Orange", "Yellow"]]); Examples

 > $\mathrm{with}\left(\mathrm{plots}\right):$

The region between $\mathrm{sin}\left(x\right)$ and $\mathrm{cos}\left(x\right)$ is filled.

 > $\mathrm{shadebetween}\left(\mathrm{sin}\left(x\right),\mathrm{cos}\left(x\right),x=0..2\mathrm{\pi },\mathrm{size}=\left[500,300\right]\right)$ The region between $\mathrm{sin}\left(x\right)$ and $\mathrm{cos}\left(x\right)$ where $\mathrm{cos}\left(x\right)<\mathrm{sin}\left(x\right)$ is filled.

 > $\mathrm{shadebetween}\left(\mathrm{sin}\left(x\right),\mathrm{cos}\left(x\right),x=0..2\mathrm{\pi },\mathrm{positiveonly},\mathrm{size}=\left[500,300\right]\right)$ Options can be provided to customize the look of the plot.

 > $\mathrm{shadebetween}\left({x}^{2},{x}^{3}-5x,x=0..4,\mathrm{axes}=\mathrm{boxed},\mathrm{color}="Niagara Azure",\mathrm{thickness}=2,\mathrm{gridlines}\right)$ The calling sequence below uses the operator form. Also, the changefill option affects the look of the filled region.

 > $\mathrm{shadebetween}\left(\mathrm{sin},\mathrm{cos},0..\mathrm{\pi },\mathrm{color}="Niagara Blue",\mathrm{thickness}=3,\mathrm{changefill}=\left[\mathrm{color}="Niagara LeafGreen",\mathrm{transparency}=0.8\right]\right)$ The fill for the positive and negative parts can have different properties.

 > $\mathrm{shadebetween}\left(\mathrm{sin},\mathrm{cos},0..\mathrm{\pi },\mathrm{color}="Niagara Blue",\mathrm{thickness}=3,\mathrm{changefill}=\left[\mathrm{color}=\left["Niagara LeafGreen","Niagara DarkOrchid"\right],\mathrm{transparency}=\left[0.4,0.8\right]\right]\right)$ The region between two surfaces in 3-D is shown below.

 > $\mathrm{shadebetween}\left(\mathrm{sin}\left(x\right)\mathrm{cos}\left(y\right),\mathrm{sin}\left(x\right)\mathrm{cos}\left(y\right)-2,x=0..\mathrm{\pi },y=0..\mathrm{\pi },\mathrm{color}="Niagara Azure",\mathrm{changefill}=\left[\mathrm{color}="Niagara Violet"\right]\right)$ The operator form is used here to create the 3-D plot, and the surfaces are omitted with the showboundary option set to false.

 > $\mathrm{shadebetween}\left(\left(u,v\right)↦\mathrm{sin}\left(u\right)\cdot \mathrm{cos}\left(v\right),\left(u,v\right)↦\mathrm{sin}\left(u\right)\cdot \mathrm{cos}\left(v\right)-2,0..\mathrm{\pi },0..\mathrm{\pi },\mathrm{showboundary}=\mathrm{false},\mathrm{changefill}=\left[\mathrm{color}="Niagara Cinnamon",\mathrm{transparency}=0.\right]\right)$ In the following example, there is no filled area in the first plot which uses the positiveonly option, since the first argument's values are always less than or equal to those of the second.

 > $\mathrm{plots}:-\mathrm{display}\left(\mathrm{Array}\left(\left[\mathrm{shadebetween}\left(-\left({x}^{2}+{y}^{2}\right),{x}^{2}+{y}^{2},x=-1..1,y=-1..1,\mathrm{grid}=\left[20,20\right],\mathrm{positiveonly}\right),\mathrm{shadebetween}\left(-\left({x}^{2}+{y}^{2}\right),{x}^{2}+{y}^{2},x=-1..1,y=-1..1,\mathrm{grid}=\left[20,20\right]\right)\right]\right)\right)$  > 

Compatibility

 • The plots:-shadebetween command was introduced in Maple 2015.