3.2 The Plotting Library

The (plotutils plot) library contains drawing primitives.

There are two important types to note: <plotter> and <plparams>. Roughly speaking, <plparams> describes the surface on which you are drawing – its size and format – and <plotter> describes the state of the virtual pen being used to draw on that surface.

3.2.1 plparams procedures

Procedure: newplparams

This procedure returns a newly allocated <plparams> in a default state.

Procedure: setplparam! plparams parameter value

This procedure modifies the state of a <plparams> object. Both parameter and value are strings. For the available parameters and values See Plotter parameters.

3.3 plotter procedures

To make a new <plotter> which is on object that keeps the state of the “pen” being used to draw on a surface, use the procedure newpl.

Procedure: newpl type outp errp param

Creates a new <plotter> object. type is the output format that will result from this plotting: one of “X”, “png”, “svg”, “pcl”, “gif”, or “pnm”. Other options may be present depending on how libplot was compiled in the upstrem GNU Plotutils library.

outp and errp should be Guile output ports. outp will receive the output produced by the plotter in the format specified by type. errp will receive error messages.

Both ports must be backed by file descriptors, such as file ports or the standard ports; string ports can’t be used. The Plotter writes to duplicates of the ports’ file descriptors rather than through the ports themselves, so to keep output in order, anything buffered in either port is written out by newpl, and again by each plotting procedure before it draws. You can therefore freely mix your own output to outp with the Plotter’s, for instance to write a header before the graphics. Closing the ports does not delete the Plotter, which keeps its own descriptors until deletepl! is called or it is garbage collected.

param is an object of type <plparams> that has set up the “paper” upon which we are drawing.