Skip to Main Content Skip to Search
Product Documentation

plot::Rasterraster plot

plot::Raster(A, x = `x_{min}`..`x_{max}`, y = `y_{min}`..`y_{max}`) translates a matrix A of RGB values into a regular 2D mesh of rectangles extending from the lower left corner (`x_{min}`, `y_{min}`) to the upper right corner (`x_{max}`, `y_{max}`). The rectangles are colored according to the color entries in A.

→ Examples

Calls:

plot::Raster(A, Options)

plot::Raster(A, x = `x_{min}` .. `x_{max}`, y = `y_{min}` .. `y_{max}`, <a = amin .. amax>, Options)

plot::Raster(L, Options)

plot::Raster(L, x = `x_{min}` .. `x_{max}`, y = `y_{min}` .. `y_{max}`, <a = amin .. amax>, Options)

Parameters:

A

an array of domain type DOM_ARRAY or a matrix of category Cat::Matrix (e.g., of type matrix or densematrix) providing RGB values or color expressions of the animation parameter a. Rows/columns of the array, respectively matrix, correspond to rows/columns of the graphical array. 
A is equivalent to the attribute ColorData.

L

a list of lists RGB values or color expressions of the animation parameter a. Each sublist of L represents a row of the graphical array. 
L is equivalent to the attribute ColorData.

x

name of the horizontal variable: an identifier or an indexed identifier. It is used as the title of the coordinate axis in x direction. 
x is equivalent to the attribute XName.

`x_{min}` .. `x_{max}`

the range of the horizontal variable: `x_{min}`, `x_{max}` must be numerical real value or expressions of the animation parameter a
`x_{min}` .. `x_{max}` is equivalent to the attributes XRange, XMin, XMax.

y

name of the vertical variable: an identifier or an indexed identifier. It is used as the title of the coordinate axis in y direction. 
y is equivalent to the attribute YName.

`y_{min}` .. `y_{max}`

the range of the vertical variable: `y_{min}`, `y_{max}` must be numerical real value or expressions of the animation parameter a
`y_{min}` .. `y_{max}` is equivalent to the attributes YRange, YMin, YMax.

See Also:

import::readbitmap, plot, plot::copy, plot::Density, plot::Inequality

Details:

Note that the bitmap data of most standard graphical formats are stored in the usual Western reading order: the first pixels correspond to the upper left corner, the last pixels correspond to the lower right corner. The utility import::readbitmap produces an array in which the first element corresponds to the lower left corner. Bitmap data imported this way can be passed directly to plot::Raster.

Arrays/matrices do not need to be indexed from 1. E.g.,

A = array(`i_{min}`..`i_{max}`, `j_{min}`..`j_{max}`, [..RGB values..])

yields a graphical array with

XMesh = `j_{max}` - `j_{min}` + 1, YMesh = `i_{max}` - `i_{min}` + 1.

If no plot range `x_{min}`..`x_{max}`, `y_{min}`..`y_{max}` is specified,

`x_{min}` = `j_{min}` - 1, `x_{max}` = `j_{max}`, `y_{min}` = `i_{min}` - 1, `y_{max}` = `i_{max}`

is used.

Example 1

We generate a raster plot:

checkerboard:= array(1..8, 1..8):
for i from 1 to 8 do
for j from 1 to 8 do
    if i + j mod 2 = 0 then
      checkerboard[i,j] := RGB::Black;
    else
      checkerboard[i,j] := RGB::White;
    end_if;
end_for:
end_for:
p := plot::Raster(checkerboard):

The plot object is rendered:

plot(p):

MuPAD graphics

delete checkerboard, p:

Example 2

We import an external bitmap file:

[width, height, colordata] := import::readbitmap("Eva.jpeg"):

The array colordata can be passed directly to plot::Raster:

scenewidth:= 80*unit::mm:
sceneheight:= height/width*scenewidth:
plot(plot::Raster(colordata),
     Width  = scenewidth,
     Height = sceneheight,
     Footer = "This is Eva"):

MuPAD graphics

delete width, height, colordata, scenewidth, sceneheight:

Example 3

This is Tom:

[widthT, heightT, Tom] := import::readbitmap("Tom.jpeg", ReturnType=DOM_ARRAY):
plot(plot::Raster(Tom), Width = widthT/3, Height = heightT/3):

MuPAD graphics

This is Jerry:

[widthJ, heightJ, Jerry] := import::readbitmap("Jerry.jpeg", ReturnType=DOM_ARRAY):
plot(plot::Raster(Jerry), Width = widthT/3, Height = heightT/3):

MuPAD graphics

Although they look different, they are topologically equivalent. We demonstrate this by deforming Tom to Jerry via a smooth map (1 - a)*T + a*J, a in [0, 1]:

blend := (T, J, a) -> zip(T, J, (t,j) -> (1-a)*t + a*j):
Tom2Jerry:= array(1..heightT, 1..widthT):
for i from 1 to heightT do
  for j from 1 to widthT do
    Tom2Jerry[i, j]:= blend(Tom[i, j], Jerry[i, j], a):
  end_for:
end_for:

The following call produces an animated plot of the deformation. Note that x and y ranges must be specified for an animation:

plot(plot::Raster(Tom2Jerry,
                  x = 1..widthT,
                  y = 1..heightT,
                  a = 0..1, Frames = 10,
                  Footer = "Tom & Jerry"),
     Width = widthT/3, Height = heightT/3):

MuPAD graphicsimage

This is the arithmetical mean of Tom and Jerry:

plot(plot::Raster(map(subs(Tom2Jerry, a = 0.5), eval)),
     Footer = "(Tom + Jerry)/2", FooterFont = [12],
     Width = widthT/3, Height = heightT/3):

MuPAD graphics

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS