next up previous contents
Next: Adding functions to your Up: Graphs Previous: Graphs   Contents

Graph Objects

To draw a graph, you first need a set of axes on which to draw it. You need to specify the domain and codomain, whether you want tick marks on the axes or a grid, where you want the axes to appear, and how large (in pixels) the final image should be.

Here is a simple example. The domain and codomain are often computed in terms of your (variable) function, so I have left them as the variables $xmin, $xmax, $ymin, $ymax. The axes option puts the axes in the usual place; the grid option indicates there will be 12 vertical grid lines and 20 horizontal ones. These too can be given by variables. When graphs are displayed they are usually displayed as a $ 100 \times 100$ thumbnail image (though this can be changed with the height and width options. In general, this seems to work well since you often have four graphs on a line. On the other hand, the thumbnail often does not display enough detail for a student to be able to answer the question, so for each thumbnail there is the original image which will pop up when you click on the thumbnail. Actually, a new browser window opens (often right on top of your existing one), with only the enlarged image displayed. The default size of this enlargement is $ 200\times 200$ pixels; I have selected a somewhat larger image specifying $ 300 \times 300$ via the pixels option.

# Set the domain of f
$xmin = -6;
$xmax = 6;

## Set the visible range
$ymin = -20;
$ymax = 20;

$graph_object = init_graph($xmin, $ymin, $xmax, $ymax,
                    'axes' => [0,0],
                    'grid' => [12,20],
                    'pixels' => [300,300]
                    );


next up previous contents
Next: Adding functions to your Up: Graphs Previous: Graphs   Contents
Thomas R. Shemanske 2002-03-05