The emu_graph Widget

emu_graph widget is a tcl-only 2D graphing package. It isn't a widget as such, rather it is a structure which can be rendered on any canvas. To use it, you create a graph with the emu_graph command, supplying options to configure the graph. This then creates a new command to manipulate the graph. Manipulations include adding one or more sets of data and configuring the appearance of the data and the graph.

You can see a demostration of the graph package if you have the Tcl plugin.

The emu_graph package is available via http://www.ics.mq.edu.au/~cassidy/tcl/emu_graph.html or you can download it directly via CANTCL http://purl.org/tcl/cantcl/package/emu-graph.zip. Please contact Steve Cassidy with any bug reports, enhancements or other queries.


Command Syntax

The emu_graph command is documented here:

emu_graph name ?options?

Options are (defaults in parentheses):

-canvas is the only required option, all others will default to sensible values. Note that if you want to set the axis limits yourself you will need to either set all limits for both axes or let the graph autorange first and then set one or more of the limits in a later call to configure.

Widget Commands

The emu_graph command creates a new command of the given name to manipulate the graph. The subcommands available are:

More about graph data

Each set of data points can be configured seperately, changing the way it will be rendered in the graph. Data is supplied as a set of coordinates, the same as the format for canvas lines. More options for supplying data may be added later. An optional mask vector can be supplied which is used along with a mask threshold to blank out parts of the plot -- at the moment this only works with point plots, not lines. Each data set has a tag and all canvas items belonging to that data set will have that tag. The options for graph data are:

The trackdata mechanism is used in the Emu system for generating plots of speech data extracted from a database, it is intended for use when there are lots of points for a line.

A Note on Coding Style

The way I've implemented this code is to have every procedure prefixed with emu_graph. Those procedures which are intended as user subcommands of a graph instance have two periods following this, eg. emu_graph..redraw, other procedures for internal use have one colon, eg emu_graph:axes.

All configuration data is stored in the global array emu_graph.