WeBWorK Problems

clutter in graphmacros?

clutter in graphmacros?

by Kenneth Appel -
Number of replies: 1
I have been reviewing the results of some 7th grade problems and discovered that
extra information seems to cause many students to avoid trying problems. I am
afraid that I may have copped out in trying to keep the graph clean by just blaming
the system.

What should I have done to avoid showing the many numbers in black that seem to insert
information provided in the initgraph instruction.
Ken Appel

DOCUMENT();
loadMacros(
"PGstandard.pl",
"PGchoicemacros.pl",
"PGgraphmacros.pl",
# "MathObjects.pl",
# "compoundProblem.pl",
"contextCurrency.pl",
#"unionLists.pl",
#"unionMacros.pl",
"contextLeadingZero.pl",
);
Context()->texStrings;
TEXT(beginproblem());
$showPartialCorrectAnswers = 1;
$graph = init_graph(-.3,-.3,6.7,6.7,pixels=>[700,700],axes=>[.279,.279],grid=>[12,12]);

# the size is 700 by 700 pixels (200 by 200 is default)
# .72 is one unit on the graph
my $im = $graph->im;
$im->setPixel(0,7,0);
# $graph->moveTo(0,0);
# $graph->lineTo(2,0,'black');
$new_label1= new Label (3.14,.162,'5','red',('bottom','left'));
$graph -> lb($new_label1);
$label2= new Label (6,.162,'10','red',('bottom','left'));
$graph -> lb($label2);
$label3= new Label (.19,3.14,'5','red',('bottom','left'));
$graph -> lb($label3);
$label4= new Label (.15,6.07,'10','red',('bottom','left'));
$graph -> lb($label4);
$label5= new Label (.19,.166,'0','red',('bottom','left'));
$graph -> lb($label5);
$label6= new Label (1.45,1.97,'B','blue',('bottom','left'));
$graph -> lb($label6);
$label7= new Label (2.03,.2,'A','blue',('bottom','left'));
$graph -> lb($label7);
$label8= new Label (4.33,4.9,'C','blue',('bottom','left'));
$graph -> lb($label8);

TEXT(image(insertGraph($graph),width=>700,height=>700));

$ansa1=3;
$ansa2=0;
$ansb1=2;
$ansb2=3;
$ansc1=7;
$ansc2=8;

BEGIN_TEXT
$PAR
A flaw in the graphing software puts some small black numbers to the below
and to the left of the axes. For this reason, all numbers on the graph
related to problems will be in colors other than black and the black numbers
should be ignored.
$PAR
The coordinates of the point labelled A are (\{ans_rule(1)\},\{ans_rule(1)\}).
$PAR
The coordinates of the point labelled B are (\{ans_rule(1)\},\{ans_rule(1)\}).
$PAR
The coordinates of the point labelled C are (\{ans_rule(1)\},\{ans_rule(1)\}).

END_TEXT
Context("LeadingZero");
ANS(Real($ansa1)->cmp);
ANS(Real($ansa2)->cmp);
ANS(Real($ansb1)->cmp);
ANS(Real($ansb2)->cmp);
ANS(Real($ansc1)->cmp);
ANS(Real($ansc2)->cmp);

ENDDOCUMENT()



In reply to Kenneth Appel

Re: clutter in graphmacros?

by Davide Cervone -
There doesn't seem to be a natural way to do what you are asking. I had thought that the init_graph_no_labels() version would do what you wanted, but it turns out only to remove the label at the origin. The labels on the ends of the axes come from the grid option. Go figure.

You could leave off the grid, but that would make it hard to tell what the coordinates are. But you could generate your own grid, which is just as good. I do that in the example below.

I'm not sure why you are using a different coordinate system for your graph than for your answers. It seems to me that your graph dimensions should be -1 to 11 and then you can enter your points and labels in that coordinate system rather than scaling by hand. I've done that below. It also makes creating the grid trivial, since the lines are at integer values.

Note also that you can combine your labels into a single call to $graph->lb(), and don't need to make variables to hold the label objects; just pass them to $graph->lb() directly. I do this in the example below.

Finally, I have made the points include an actual marker using circle stamps. These are closed circles, but closed_circle() was too big, so I used the underlying Circle object.

Here's my example:


    $graph = init_graph_no_labels(-1,-1,11,11, pixels=>[500,500], axes=>[0,0]);
    $graph->v_grid('gray',0..10);
    $graph->h_grid('gray',0..10);

    $dx = .075;
    $graph->lb(
      new Label (5+$dx,0,'5','black',('bottom','left')),
      new Label (10+$dx,0,'10','black',('bottom','left')),
      new Label ($dx,5,'5','black',('bottom','left')),
      new Label ($dx,10,'10','black',('bottom','left')),
      new Label ($dx,0,'0','black',('bottom','left')),
    );

    $dx = .11; $dy = .03;
    $graph->lb(
      new Label(3+$dx,$dy,'A','blue',('bottom','left')),
      new Label(2+$dx,3+$dy,'B','blue',('bottom','left')),
      new Label(7+$dx,8+$dy,'C','blue',('bottom','left')),
    );
    $graph->stamps(
      new Circle(3,0,2.5,'blue','blue'),
      new Circle(2,3,2.5,'blue','blue'),
      new Circle(7,8,2.5,'blue','blue'),
    );

    TEXT(image(insertGraph($graph),width=>500,height=>500));

it would be possible to use Point objects to do both the point labels and the answer checking (even with the LeadingZero context, I think), rather than checking the individual coordinates by hand, but you may be wanting to do it that way so the students don't have to type parentheses and commas themselves. It depends on what you are testing, I guess.

Davide