## WeBWorK Problems

### Grid lines not showing up on graphs ### Grid lines not showing up on graphs

by Robin Cruz -
Number of replies: 1

My graphs are not showing up with all of their grid lines online.  If I look at the hardcopy, all the grid lines are showing up.  Two days ago, the grid lines were showing up online and on the hardcopy.  Note that I have upgraded the pg folder since then from CVS.

Thanks -- rac

Here is the code:

#------------Define the graph-----------------------

$choose = random(0,2,1); @colors = ("blue", "red", "green");$rc = $colors[$choose];   #Pick a random color

$xmin = -6;$ymin = -6;
$xmax = 6;$ymax = 6;

$graph = init_graph_no_labels($xmin,$ymin,$xmax,$ymax, 'axes'=>[0,0],'grid'=>[$xmax-$xmin,$ymax-$ymin]);$f_graph = FEQ("$f for x in$interval[$n] using color:$rc and weight:3");
add_functions( $graph,$f_graph );

$label = new Label($xmin+1,$ymax-.5, "y = h(x)",'black','center');$graph->lb($label);$i = 0;           # Number the axes
do {
$xtick =$i + $xmin + 1;$labelx[$i] = new Label($xtick,0, "$xtick",'black','center'); if ($xtick!=0) {$graph->lb($labelx[$i]);}$i =$i+1; } while ($i<($xmax-$xmin)-1);

$i = 0; do {$ytick = $i +$ymin + 1;
$labely[$i] = new Label(-.2,$ytick+.1, "$ytick",'black','center');
if ($ytick!=0) {$graph->lb($labely[$i]);}
$i =$i+1;
} while ($i<($ymax-\$ymin)-1); In reply to Robin Cruz

### Re: Grid lines not showing up on graphs

by Davide Cervone -
I suspect that the issue is that the image shown in the browser is a reduced version of the actual, larger image. Web browsers are notoriously bad at reducing the images, and things like thin vertical and horizontal lines are often lost in the process. You didn't include the portion of code where the image is actually displayed, so I can't tell for sure, but I know that was an issue in early versions of problems I was writing.

Many problems include small versions of the graphs that are produced this way, and that link to the larger version; but I've never found that an effective approach. The small versions are pretty useless, and you pretty much have to link to the larger one in order to see anything. So why not just provide the larger version automatically?

The unionImage.pl file includes an Image() macro that makes it easier to generate larger, single, unlinked images. If you really a small version and a large one, I recommend creating two images explicitly, one large and one small, rather than letting the browser do it, since browsers are so bad at it. There is support in the Image() macro for having one image link to another. (See the comments in the file.)

Good luck.

Davide