WeBWorK Problems

dynamically generated number lines

Re: dynamically generated number lines

by Bruce Yoshiwara -
Number of replies: 0
By the way, so far I'm using this (which works, but someone may have something better):

$a = random(-5,5,1);
$b = random($a+1,$a+6,1);

$gr = init_graph(-6,-1,6,1, 'size' => [400,80],
'axes' => [$a-100,0]);

add_functions($gr, "0 for x in " .
"using color:blue and weight:2");

$gr->stamps( closed_circle($a,0,'blue') );
$gr->stamps( open_circle($b,0,'blue') );
$gr->lb( new Label($a,-.5,$a,
'black','center','middle'));
$gr->lb( new Label($b,-.5,$b,
'black','center','middle'));

$image = image(insertGraph($gr),
height=>50, width=>250 ) ;