Home : Maplesoft Products : Maple 18 : New Features in Maple 18 : Customizing Size and Background on 2-D Plots

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.

> with(ImageTools); -1
with(plots); -1
with(plottools); -1

 

Setting the Size of the Plot Window

 Example

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

> plot(sin(x), size = [500, 300], axes = box)
 
Plot_2d

 Example

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

> plot(sin(x), size = [.75, 350], axes = box)
 
Plot_2d

 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. 

> plot(sin(x), size = [
 
Plot_2d

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.

Embedded component

>
 
Plot_2d

 

 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.

> restart; -1
 
> with(ImageTools); -1with(plots); -1with(plottools); -1
 
> p := `+`(`*`(`^`(x, 5)), `-`(`*`(`^`(x, 2))), `-`(200)); -1
 
> sols := `~`[[Re, Im]]([fsolve(p, x, complex)])
 
[[HFloat(-2.3269146520061947), HFloat(-1.718843776327277)], [HFloat(-2.3269146520061947), HFloat(1.718843776327277)], [HFloat(0.8722043272797415), HFloat(-2.730057236865024)], [HFloat(0.87220432727974...
[[HFloat(-2.3269146520061947), HFloat(-1.718843776327277)], [HFloat(-2.3269146520061947), HFloat(1.718843776327277)], [HFloat(0.8722043272797415), HFloat(-2.730057236865024)], [HFloat(0.87220432727974...
 
> a, b := -3, 3
 
-3, 3
 
> img := Fractals:-EscapeTime:-Newton(400, `+`(a, `*`(I, `*`(a))), `+`(b, `*`(I, `*`(b))), p)
 
Array(%id = 18446744074376520518)
 
> plot(sols, style = point, symbol = diagonalcross, view = [a .. b, a .. b], background = img)

 

Plot_2d

Setting a Background Color

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

 Example

> plot(sin(x), x = `+`(`-`(`*`(2, `*`(Pi)))) .. `+`(`*`(2, `*`(Pi))), axis = [color = white], background =
 
Plot_2d

> plot(`+`(cos(x), x), x = `+`(`-`(`*`(2, `*`(Pi)))) .. `+`(`*`(2, `*`(Pi))), color =
 
Plot_2d