Object Reference : Object View and Procedure Reference : Graph
  
 
addrect
Draw a rectangle on a graph.
Syntax
graph_name.addrect[pos(x1,y1,x2,y2) axisctr(x1,y1,x-axis,y-axis) axispos(x1,y1,y-axis)] linewidth(lwidth) color(color) pattern(pattern) height(height) width(width) angle(angle)
Follow the addrect keyword a set of specifications determining the position and style of the rectangle to be drawn.
The position and size of the rectangle can be specified with either the pos or axisctr arguments.
The pos argument specifies coordinates of the center of the rectangle in virtual space. x1 is the center point X (horizontal) coordinate, and y1 is the center point Y (vertical) coordinate. Coordinates are set in virtual inches. Individual graphs are always virtual inches (scatter diagrams are virtual inches) or a user-specified size, regardless of their current display size.
The origin of the coordinate is the upper left hand corner of the graph. The x1 number specifies how many virtual inches to offset to the right from the origin. The second number y1 specifies how many virtual inches to offset below the origin.
The axisctr argument specifies coordinates in units of the graph scale. x1 is the center point X (horizontal) coordinate, and y1 is the center point Y (vertical) coordinate.
For time-series graphs you must also specify which non-time based axis the y-coordinates’s scale are based on, using l,t,r,b for left, top, right, bottom respectively. x-coordinates should be specified as a date/time.
For non-time series graphs you must specify the axis of scale of both x and y coordinates.
The height argument specifies the height of the rectangle. Similarly the width argument specifies its width. angle controls the rotation of the rectangle (in degrees).
The linewidth argument specifies the thickness of the rectangle outline. lwidth should be a number between “.25” and “5”, indicating the width in points.
arrowwidth determines the size of the arrow head on the line. awidth can be either “small”, “medium” or “large”.
color specifies the color of the rectangle outline. The color value may set by using one of the color keywords (e.g., “blue”), or by using the RGB values (e.g., “@RGB(255, 255, 0)”). For a description of the available color keywords (“blue”, “red”, “green”, “black”, “white”, “purple”, “orange”, “yellow”, “gray”, “ltgray”). For a full description of the keywords, see Table::setfillcolor.
The pattern argument specifies the rectangle outline pattern. pattern can take a numerical value, or one of the corresponding keywords:
Examples
The commands
create m 1990 2000
smpl 1990 1995
series y=nrnd
smpl 1995 2000
y = 6+nrnd
smpl @all
freeze(gr) y.line
gr.addrect pos(1,1) width(2) height(.7) angle(110) color(red) pattern(2) linewidth(3)
create a graph and adds a red rectangle that is centered 1 virtual inch from the top and 1 virtual inch from the left of the graph that is 2 virtual inches wide and 0.7 virtual inches tall. It uses a 3 pt dash1 line pattern. The rectangle is also rotated 110 degrees
The command
gr.addrect axisctr(1995, @mean(x),l) width(30) height(.2) angle(-50) color(blue)
adds to a blue rectangle that is centered at 1995 and the mean of x in left axis units. It is 30 observations wide and 0.2 left axis units tall. It is also rotated -50 degrees
Cross-references
See “Drawing Lines and Arrows” for discussion.
See Graph::addarrow, Graph::addellipse and Graph::addtext. See also Graph::legend and Graph::textdefault.