Axis configuration is a fundamental aspect of data visualization in GNU Octave, allowing users to control the spatial boundaries, scaling, and appearance of plots. The primary mechanism for this is the axis function, which modifies properties of the current axes object to define limits and display options. This function is essential for tailoring plots to specific data ranges, ensuring clarity in scientific and engineering applications. By default, high-level plotting functions such as plot reset axes properties, so any customization must occur after the plot is generated or by first invoking the hold function to preserve existing settings.
The axis function supports multiple invocation styles to address different configuration needs. It can be called without arguments to retrieve the current axis limits, or with a vector argument to set them explicitly. The limits vector can vary in length to specify boundaries for different axes. For a two-dimensional plot, a four-element vector [x_lo, x_hi, y_lo, y_hi] sets the lower and upper limits for the x-axis and y-axis, respectively. In three-dimensional plots, a six-element vector [x_lo, x_hi, y_lo, y_hi, z_lo, z_hi] extends this to include the z-axis. Additionally, an eight-element vector [x_lo, x_hi, y_lo, y_hi, z_lo, z_hi, c_lo, c_hi] can be used to set limits for the color axis, which is particularly useful for plots involving color mapping, such as heatmaps or contour plots. When called with a two-element vector [x_lo, x_hi], only the x-axis limits are adjusted, leaving other axes unchanged.
Beyond limit setting, the axis function accepts option arguments to control various axis properties. These options allow for quick adjustments to the aspect ratio, visibility of the box around the axes, or the orientation of the plot. Multiple options can be passed in a single call, and the function can also target a specific axes handle hax if multiple plots are present. The return value, when requested, provides a vector of the current axis limits, enabling programmatic access to plot boundaries for further calculations or adjustments.
Complementing the axis function are several properties of the axes object that can be queried or modified directly. These properties offer granular control over the plot's appearance and behavior. For instance, the position property is a four-element vector specifying the coordinates of the lower-left corner and the width and height of the plot in normalized units (ranging from 0 to 1). An example value [0.2, 0.3, 0.4, 0.5] positions the lower-left corner at (0.2, 0.3) with a width of 0.4 and height of 0.5 relative to the figure window. Similarly, the outerposition property defines the outer boundaries of the axes, which is useful for layout management in multi-plot figures.
The dataaspectratio property influences how data is displayed by specifying the relative height and width of the data within the axes. For example, setting dataaspectratio to [1, 2] results in the length of one unit on the y-axis appearing equal to the length of two units on the x-axis, effectively stretching the y-axis display relative to the x-axis. This property helps maintain proportional representations of data when the default scaling does not suit the visualization needs.
Other key properties include those controlling the display of elements such as the title, box, and legend. The title property holds the index of a text object for the axes title. The box property toggles the display of a box around the axes and can be set to "on" or "off". The key property toggles the display of a legend, though it is noted as incompatible with MATLAB and may be removed in future Octave versions. Relatedly, keybox toggles a box around the legend, and keypos specifies the legend's position using integers 1 to 4 (1 for upper right, 2 for upper left, 3 for lower left, 4 for lower right), both of which are also noted as non-MATLAB compatible.
Scaling and direction of axes are controlled by properties like xscale, yscale, and zscale, which can be set to "linear" or "log" for logarithmic scaling. The direction of the axes is determined by xdir, ydir, and zdir, with options "forward" (increasing from left to bottom) or "reverse" (decreasing). For axis placement, xaxislocation can be "top" or "bottom", and yaxislocation can be "left" or "right". The view property, a three-element vector, sets the viewpoint for three-dimensional plots. The visible property toggles the entire axes display ("on" or "off"), and nextplot determines how subsequent plots are added, with options "new", "add", "replace", or "replacechildren".
For tick label customization, tick label modes such as xticklabelmode, yticklabelmode, and zticklabelmode can be set to "manual" or "auto", allowing control over whether labels are automatically generated or user-specified. Rotation of tick labels is managed via functions xtickangle, ytickangle, and ztickangle. These functions query or set the rotation angle in degrees for the respective axis tick labels, using the properties "XTickLabelRotation", "YTickLabelRotation", and "ZTickLabelRotation". When called without arguments, they return the current angle; with a numeric scalar, they rotate labels counterclockwise. However, a critical programming note across these rotation properties is that they are currently unimplemented in Octave: setting or querying them has no effect on the plot, though the properties themselves can be manipulated.
Similarly, for polar plots, the thetaticklabels function manages labels for theta tick marks. Labels are applied starting at the zero-degree tick mark and progress counterclockwise. If fewer labels are provided than tick marks, blank labels fill the remainder; excess labels are ignored. Attempting to retrieve a return value when setting labels results in an error. The 'mode' property for thetaticklabels is also unimplemented, and compatibility notes indicate these features are not fully supported compared to MATLAB.
In summary, axis configuration in GNU Octave provides robust tools for plot customization through the axis function and direct property manipulation. Users can precisely control limits, aspect ratios, scaling, and label appearance to enhance data visualization. While many features align with MATLAB compatibility, some, like tick label rotation and certain legend properties, have limitations or are unimplemented, requiring users to verify functionality in their specific Octave version.