The box pseudo object




The box pseudo object creates a frame, usually containing several other pseudo objects or ordinary Matlab graphical objects. The primary benefit is to create a visual grouping of objects used for a similar purpose. It also makes it easier to design the user interface layout because dragging the box pseudo object to a new location also moves all the controls that are inside it.

A box pseudo object may be created with any one of these commands:

H = plt('box',pos,
    'Property1',Value1,
    'Property2',Value2,...)
A new axis is created to group other user interface control objects. pos specifies the position of the axis object as [xleft ybottom width height]. If all four of these numbers are less than 5, normalized units are assumed, otherwise, pixel units are used. If any property/value pairs (optional) appear in the argument list, these properties are applied to the axis object created. The handle of the new axis is returned in H.
H = plt('box',pos,[r g b],
    'Property1',Value1,
    'Property2',Value2,...)
This is equivalent to:
H = plt('box',pos,'color',[r g b],'PropName1',PropValue1,...)
You can use either of the alternate color specification methods described in the the color section. So for example, the following two commands are equivalent:
plt('box',pos,[.66 .11 .77]);
plt('box',pos,661177);
You can also use the string 'none' to indicate that the axis background color should be the same as the figure background color.
(Other character string color representations such as 'blue' are not allowed here.)
H = plt('box',pos,[r g b],
    [R G B],
    'Property1',Value1,
    'Property2',Value2,...)
This is equivalent to:
H = plt('box',pos,'color',[r g b],'xcolor',[R G B],'ycolor',[R G B],'PropName1',PropValue1,...)
This surrounds the box with a border of the specified color. The default linewidth of this border is 3 but can be changed by using 'linewidth' as one of the property names in the argument list. As before, you may replace [R G B] with a single number using the alternate color format but you can't use a string such as 'red'.

As an example, the demo program afilt.m (or the simplified version afiltS.m) includes the following line:

plt('box',p{2}); % where p{2} had been defined earlier as [.108 .888 .228 .088] (normalized position)

This is the box that is created from that command.
(The objects inside the box were created by the other code in the program.)
The color of the box is the default value of [1 1 1]/12 (a very dark gray).


If you don't like the default box color, just supply a third parameter.
The dark blue box shown here was created with the command:
plt('box',p{2},30);.
In place of the "30" you could have used "000030" for more clarity or used [0 0 .3] (Maltab's traditional color triple format).


Using a transparent box, i.e. plt('box',p{2},'none'); would look like this.
When you specify 'none' for the box color a gray ([.5 .5 .5]) border is used by default.


Or if you wanted a brighter (white) but thinner box you could use a command such as:
plt('box',p{2},'none',010101,'Linewidth',1);


One final (slightly garish) example using a dark green box with a blue border:
plt('box',p{2},1500,1);


Creating multiple pseudo boxes with one command

If the first argument (pos) is a cell array of length n, then the command creates n pseudo box objects., If a parameter is a cell array of length n, then the nth element of that cell array is used for the corresponding parameter for each pseudo box object. Otherwise, the entire parameter is used for the corresponding parameter of every pseudo box object. For example, try typing the following command into the command window:

plt('box',arrange(20));

This will create 20 pseudo boxes 'arranged' somewhat haphazardly around the figure. Now let's glorify this example by adding some more parameters:

plt('box',arrange(20),num2cell(rand(20,3),2),80,'linewidth',5);

The first additional parameter is a cell array containing 20 random color triples so that each box is a different color. The next parameter (80) specifies that each box will have a dark blue border. The 80 is one of the alternate methods of specifying colors with plt and is shorthand for the Matlab color triple [0 0 .8]. The final parameter changes the border width from its default of 2 to a thicker 5. After adding these three parameters, the command will produce a figure such as shown here to the right. (Of course every time you type this command, the figure will look somewhat different because box colors are random.

See the following programs for more examples of the use of the pseudo box object:
      demo folder:   gui1, pltmap, xChart
      math folder: carlo, gpsLog
      sig folder: afilt, editz, erip, fseries
      util folder: pltwater