Customizing Size and Background on 2-D Plots - Maple Programming Help Customizing Size and Background on 2-D Plots

Two new options, background  and size for 2-D plotting commands, allow you to superimpose a plot on a background image, set a background color or specify the size of the plot window.

 > $\mathrm{with}\left(\mathrm{ImageTools}\right):$$\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\mathrm{with}\left(\mathrm{plots}\right):$$\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\mathrm{with}\left(\mathrm{plottools}\right):$

Setting the Size of the Plot Window

Example

The width and height of the plot window can be given as the number of pixels.

 > $\mathrm{plot}\left(\mathrm{sin}\left(x\right),\mathrm{size}=\left[500,300\right],\mathrm{axes}=\mathrm{box}\right)$ Example

If the width is given as a floating-point number, it is interpreted as a proportion of the worksheet width.

 > $\mathrm{plot}\left(\mathrm{sin}\left(x\right),\mathrm{size}=\left[0.75,350\right],\mathrm{axes}=\mathrm{box}\right)$ Example

If the height is given as a floating-point number, it is interpreted as the ratio of the height to the width. The height can be the special name "golden"; in this case, the height/width ratio is the reciprocal of the golden ratio.

 > $\mathrm{plot}\left(\mathrm{sin}\left(x\right),\mathrm{size}=\left["default","golden"\right],\mathrm{axes}=\mathrm{box}\right)$ Using an Image as the Background

The image can be specified as either a name (string) of an image file or an image (array) usable by the package. By default, the plot is displayed with the dimensions of the image.

Example

The following example shows the location of all earthquakes of magnitude 2.5 or greater over a seven day period.

Reference: Data compiled by the U.S. Geological Survey.

Code to get Earthquake data.
 > > 

Example

An image that can be produced or used with the ImageTools package can also be used as the background. The Fractals package can also produce such images.

 > $\mathrm{restart}:$
 > $\mathrm{with}\left(\mathrm{ImageTools}\right):$$\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\mathrm{with}\left(\mathrm{plots}\right):$$\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\mathrm{with}\left(\mathrm{plottools}\right):$
 > $p:={x}^{5}-{x}^{2}-200:$
 > $\mathrm{sols}≔\left[\mathrm{ℜ},\mathrm{ℑ}\right]~\left(\left[\mathrm{fsolve}\left(p,x,\mathrm{complex}\right)\right]\right)$
 ${\mathrm{sols}}{:=}\left[\left[{-}{2.32691465200619}{,}{-}{1.71884377632728}\right]{,}\left[{-}{2.32691465200619}{,}{1.71884377632728}\right]{,}\left[{0.872204327279742}{,}{-}{2.73005723686502}\right]{,}\left[{0.872204327279742}{,}{2.73005723686502}\right]{,}\left[{2.90942064945291}{,}{0.}\right]\right]$ (2.1)
 > $a,b:=-3,3$
 ${a}{,}{b}{:=}{-}{3}{,}{3}$ (2.2)
 > $\mathrm{img}:=\mathrm{Fractals}:-\mathrm{EscapeTime}:-\mathrm{Newton}\left(400,a+aI,b+bI,p\right)$
 ${\mathrm{img}}{:=}\left[\begin{array}{c}{\mathrm{1..400 x 1..400 x 1..3}}{\mathrm{Array}}\\ {\mathrm{Data Type:}}{{\mathrm{float}}}_{{8}}\\ {\mathrm{Storage:}}{\mathrm{rectangular}}\\ {\mathrm{Order:}}{\mathrm{C_order}}\end{array}\right]$ (2.3)
 > $\mathrm{plot}\left(\mathrm{sols},\mathrm{style}=\mathrm{point},\mathrm{symbol}=\mathrm{diagonalcross},\mathrm{view}=\left[a..b,a..b\right],\mathrm{background}=\mathrm{img}\right)$ Setting a Background Color

The background option can also be used to set the background color.

Example

 > $\mathrm{plot}\left(\mathrm{sin}\left(x\right),x=-2\mathrm{π}..2\mathrm{π},\mathrm{axis}=\left[\mathrm{color}=\mathrm{white}\right],\mathrm{background}="Black"\right)$ > $\mathrm{plot}\left(\mathrm{cos}\left(x\right)+x,x=-2\mathrm{π}..2\mathrm{π},\mathrm{color}="Black",\mathrm{background}="Goldenrod",\mathrm{size}=\left[0.75,0.5\right]\right)$ 