Documentation Center

  • Trial Software
  • Product Updates

plot::Raster

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

plot::Raster(A, options)
plot::Raster(A, x = xmin .. xmax, y = ymin .. ymax, <a = amin .. amax>, options)
plot::Raster(L, options)
plot::Raster(L, x = xmin .. xmax, y = ymin .. ymax, <a = amin .. amax>, options)

Description

plot::Raster(A, x = xmin..xmax, y = ymin..ymax) translates a matrix A of RGB values into a regular 2D mesh of rectangles extending from the lower left corner (xmin, ymin) to the upper right corner (xmax, ymax). The rectangles are colored according to the color entries in A.

plot::Raster serves for generating 2D raster objects such as bitmaps. External bitmap data can be imported to a MuPAD® session via import::readbitmap. The resulting array of color values can be passed directly to plot::Raster to embed the imported bitmap in a 2D MuPAD scene.

When color values are specified by an array or a matrix A, the low indices correspond to the lower left corner of the graphics. The high indices correspond to the upper right corner.

    Note:   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( imin..imax, jmin..jmax, [..RGB values..])

yields a graphical array with

XMesh = jmax - jmin + 1, YMesh = imax - imin + 1.

If no plot range xmin..xmax, ymin..ymax is specified,

xmin = jmin - 1, xmax = jmax, ymin = imin - 1, ymax = imax

is used.

When color values are specified by a list of lists L, the first entries in the list correspond to the lower left corner of the graphics. The last entries correspond to the upper right corner.

If no plot range xmin..xmax, ymin..ymax is specified,

xmin = 0, xmax = m, ymin = 0, ymax = n

is used, where n is the length of L and m is the (common) length of the sublists in L. All sublists ("rows") must have the same length.

Animations are triggered by specifying a range a = amin .. amax for a parameter a that is different from the variables x, y. Thus, in animations, both the ranges x = xmin..xmax, y = ymin..ymax as well as the animation range a = amin..amax must be specified.

The related plot routine plot::Density provides a similar functionality offering an automatic color scheme based on scalar density values.

Attributes

AttributePurposeDefault Value
AffectViewingBoxinfluence of objects on the ViewingBox of a sceneTRUE
AntiAliasedantialiased lines and points?FALSE
Colorthe main colorRGB::Blue
ColorDatacolor values of a raster plot 
Framesthe number of frames in an animation50
Legendmakes a legend entry 
LegendTextshort explanatory text for legend 
LegendEntryadd this object to the legend?FALSE
LineColorcolor of linesRGB::Blue
LineWidthwidth of lines0.35
LineStylesolid, dashed or dotted lines?Solid
LinesVisiblevisibility of linesFALSE
Meshnumber of sample points[11, 11]
Namethe name of a plot object (for browser and legend) 
ParameterEndend value of the animation parameter 
ParameterNamename of the animation parameter 
ParameterBegininitial value of the animation parameter 
ParameterRangerange of the animation parameter 
TimeEndend time of the animation10.0
TimeBeginstart time of the animation0.0
TimeRangethe real time span of an animation0.0 .. 10.0
Titleobject title 
TitleFontfont of object titles[" sans-serif ", 11]
TitlePositionposition of object titles 
TitleAlignmenthorizontal alignment of titles w.r.t. their coordinatesCenter
TitlePositionXposition of object titles, x component 
TitlePositionYposition of object titles, y component 
VisiblevisibilityTRUE
VisibleAfterobject visible after this time value 
VisibleBeforeobject visible until this time value 
VisibleFromToobject visible during this time range 
VisibleAfterEndobject visible after its animation time ended?TRUE
VisibleBeforeBeginobject visible before its animation time starts?TRUE
XMaxfinal value of parameter "x" 
XMeshnumber of sample points for parameter "x"11
XMininitial value of parameter "x" 
XNamename of parameter "x" 
XRangerange of parameter "x" 
YMaxfinal value of parameter "y" 
YMeshnumber of sample points for parameter "y"11
YMininitial value of parameter "y" 
YNamename of parameter "y" 
YRangerange of parameter "y" 

Examples

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):

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"):

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):

This is Jerry:

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

Although they look different, they are topologically equivalent. We demonstrate this by deforming Tom to Jerry via a smooth map (1 - a) T + aJ, a ∈ [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):

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):

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.

xmin .. xmax

The range of the horizontal variable: xmin, xmax must be numerical real value or expressions of the animation parameter a.

xmin .. xmax 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.

ymin .. ymax

The range of the vertical variable: ymin, ymax must be numerical real value or expressions of the animation parameter a.

ymin .. ymax is equivalent to the attributes YRange, YMin, YMax.

a

Animation parameter, specified as a = amin..amax, where amin is the initial parameter value, and amax is the final parameter value.

See Also

MuPAD Functions

MuPAD Graphical Primitives

Was this topic helpful?