Next Previous Contents

8. Plotting

SLgtk also wraps much of the functionality of the

widgets from the GtkExtra widget set, with the aim of providing a lightweight mechanism for 2D plotting and data exploration, with support for PostScript hardcopy. While these functions may be used interactively, as is, they are probably more suitable as building blocks for higher-level plotting functions. Towards that end SLgtk introduces the GtkPlotDescriptor S-Lang type, a structured container, which can be created and manipulated by the functions described below. Examples of their use may be gleaned from the vwhere guilet described above.

8.1 _gtk_plot

        GtkPlotDescriptor = _gtk_plot(x, y [,color [, style]])
This function will create a plot canvas, draw upon it an 2D scatterplot from the given vectors (optionally in the given line color and style), and return an S-Lang structure containing both. To visualize the result, add the canvas field of the returned structure to a suitable container.

A custom canvas size may be specified via the width= and height= qualifiers, in units of pixels.

8.2 _gtk_oplot

       _gtk_oplot(GtkPlotDescriptor, x, y, [, color [, style]])

This function will overplot the given vectors (optionally in the given line color and style) upon the canvas contained within the given plot descriptor. A custom canvas size may be specified via the width= and height= qualifiers, in units of pixels.

8.3 _gtk_plot_set_x_range, _gtk_plot_set_y_range

        _gtk_plot_set_xrange(GtkPlotDescriptor, xmin, xmax)
        _gtk_plot_set_yrange(GtkPlotDescriptor, ymin, ymax)

These functions customize the tick marks of the bounding box in which the plots are displayed.

8.4 _gtk_plot_redraw

        _gtk_plot_redraw(GtkPlotDescriptor)
This is a convenience function which repaints the internal canvas pixmap and then refreshes the current display with the new pixmap. Note that plots containing many points may require several seconds to perform this combined action. If multiple canvas operations are to be performed -- each of which logically induce a repaint -- a better choice may be to avoid this function altogether, and instead freeze the canvas, perform the necessary operations, thaw the canvas, and then paint the canvas or refresh the display explicitly.

8.5 _gtk_plot_remove

        _gtk_plot_remove(GtkPlotDescriptor, i)
Eliminate the ith plot from the given descriptor, causing it to be erased from the display upon the next redraw. The index i may take the values 1 through N, where N is the number of plots that have been drawn to the descriptor.


Next Previous Contents