Plot.DrawBeginBlock

Prototypes

void DrawBeginBlock( String sBlockName )

Parameters

String sBlockName
The name to assign to the new block of drawing commands. The name must be at least one character long, but there is no limit to its length. The name can contain any characters.

Remarks

This method is used in conjunction with the method Plot.DrawEndBlock to delimit a block of drawing commands. Delimiting a block of drawing commands enables you to remove the block using the method Plot.DrawRemoveCommands without disturbing other drawing commands.

When defining blocks of drawing commands, it is best for each block to operate independently of other blocks. It is recommended that each block be structured as follows:

plot.DrawBeginBlock( "Some Block Name" );

plot.DrawPushState();

plot.DrawResetState();

...

plot.DrawPopState();

plot.DrawEndBlock();

You can nest blocks one within another, but every block must have a unique name.

Example
x = T(50:100);
y = x + 10*normal(j(51,1,1234));
/* add outliers */
x = x // {2, 3, 4, 5};
y = y // {100, 95, 89, 93};
 
declare ScatterPlot plot;
plot = ScatterPlot.Create( "Outliers", x, y );
 
/* robust and non-robust regression estimates */
fitX = {0, 100};
robustFit = 6.6333 + 0.9349 * fitX;
leastSqFit = 59.41889 + 0.24689 * fitX;
 
plot.DrawUseDataCoordinates();
plot.DrawSetPenColor( RED );
plot.DrawLine( fitX[1], robustFit[1], fitX[2], robustFit[2] );
 
plot.DrawBeginBlock( "Least Square Regression" );
plot.DrawSetPenColor( BLACK );
plot.DrawLine( fitX[1], leastSqFit[1], fitX[2], leastSqFit[2] );
plot.DrawText( 20, 70, "LS Fit" );
plot.DrawEndBlock();
 
plot.DrawSetTextColor( RED );
plot.DrawText( 20, 40, "Robust Fit" );
 
run DoMessageBoxOK( "Continue",
    "Press OK to remove the least squares fit" ); 
 
plot.DrawRemoveCommands( "Least Square Regression" );
See Also

Plot.DrawEndBlock
Plot.DrawRemoveCommands