AXES OBJECT

This is a hash to store information about the axes (ticks, range, grid, etc) with some helper methods. The hash is further split into three smaller hashes: xaxis, yaxis, and styles.

xaxis

Hash of data for the horizontal axis.

yaxis

Hash of data for the vertical axis.

styles

Hash of data for options for the general axis.

USAGE

The axes object should be accessed through a Plots object using $plot->axes. The axes object is used to configure and retrieve information about the axes, as in the following examples.

Each axis and styles can be configured individually, such as:

$plot->axes->xaxis(min => -10, max => 10,  tick_delta => 4);
$plot->axes->yaxis(min => 0,   max => 100, tick_delta => 20);
$plot->axes->style(ariaLabel => 'Graph of function y = f(x).', show_grid => 0);

This can be combined using the set method by prepending either x or y in front of each key of the axes to configure (note keys that do not start with x or y sent to $plot->axes->style):

$plot->axes->set(
    xmin        => -10,
    xmax        => 10,
    xtick_delta => 4,
    ymin        => 0,
    ymax        => 100,
    ytick_delta => 20,
    ariaLabel   => 'Graph of function y = f(x).',
    show_grid   => 0,
);

The same methods also get the value of a single option, such as:

$xmin        = $plot->axes->xaxis('min');
$ytick_delta = $plot->axes->yaxis('tick_delta');
$show_grid   = $plot->axes->style('show_grid');

The methods without any inputs return a reference to the full hash, such as:

$xaxis  = $plot->axes->xaxis;
$styles = $plot->axes->style;

It is also possible to get multiple options for both axes using the get method, which returns a reference to a hash of requested keys, such as:

$bounds = $plot->axes->get('xmin', 'xmax', 'ymin', 'ymax');
# The following is equivlant to $plot->axes->grid
$grid = $plot->axes->get('xmajor', 'xminor', 'xtick_delta', 'ymajor', 'yminor', 'ytick_delta');

It is also possible to get the bounds as an array in the order xmin, ymin, xmax, ymax using the $plot->axes->bounds method.

AXIS CONFIGURATION OPTIONS

Each axis (the xaxis and yaxis) has the following configuration options:

min

The minimum value the axis shows. Default is -5.

max

The maximum value the axis shows. Default is 5.

tick_num

This is the number of major tick marks to include on the axis. This number is used to compute the tick_delta as the difference between the max and min values and the number of ticks. Default: 5.

tick_delta

This is the distance between each major tick mark, starting from the origin. If this is set to 0, this distance is set by using the number of ticks, tick_num. Default is 0.

tick_labels

This can be either 1 (show) or 0 (don't show) the labels for the major ticks. Default: 1

show_ticks

This can be either 1 (show) or 0 (don't show) the tick lines. If ticks are not shown then tick labels won't be shown either. Default: 1

label

The axis label. Defaults are \(x\) and \(y\).

major

Show (1) or don't show (0) grid lines at the tick marks. Default is 1.

minor

This sets the number of minor grid lines per major grid line. If this is set to 0, no minor grid lines are shown. Default is 3.

visible

This sets if the axis is shown (1) or not (0) on the plot. Default is 1.

location

This sets the location of the axes relative to the graph. The possible options for each axis are:

xaxis  =>  'top', 'middle', 'bottom'
yaxis  =>  'left', 'center', 'right'

This places the axis at the appropriate edge of the graph. If 'center' or 'middle' are used, the axes appear on the inside of the graph at the appropriate axis position. Default 'middle' or 'center'.

position

The position in terms of the appropriate variable to draw the axis if the location is set to 'middle' or 'center'. Default is 0.

jsx_options

A hash reference of options to be passed to the JSXGraph axis objects.

STYLES

The following styles configure aspects about the axes.

aspect_ratio

If this style is set, then the height of the graph will be computed using this aspect_ratio for the size of the image unless explicitly set. Default: ''

ariaLabel

The ARIA label in JSX graph output. Default is 'Graph'.

ariaDescription

The ARIA description in JSX graph output. This will be set to the images alt tag. Default is 'Generated graph'.

show_grid

Either draw (1) or don't draw (0) the grid lines for the axis. Default is 1.

grid_color

The color of the grid lines. Default is 'gray'.

grid_alpha

The alpha value to use to draw the grid lines in Tikz. This is a number from 0 (fully transparent) to 100 (fully solid). Default is 40.

axis_on_top

Configures if the Tikz axis should be drawn on top of the graph (1) or below the graph (0). Useful when filling a region that covers an axis, if the axis are on top they will still be visible after the fill, otherwise the fill will cover the axis. Default: 0

jsx_navigation

Either allow (1) or don't allow (0) the user to pan and zoom the view port of the JSXGraph. Best used when plotting functions with the continue style. Note that if this option is 0, then the image can be clicked on to open a dialog showing a magnified version of the graph that can be zoomed in or out. Default: 0

jsx_options

A hash reference of options to be passed to the JSXGraph board object.