SYNOPSIS
stripchart pathName ?option value?...DESCRIPTION
The stripchart command creates a strip chart for plotting two-dimensional data (x,y coordinates). It has many configurable components: coordinate axes, elements, legend, grid lines, cross hairs, etc. They allow you to customize the look and feel of the strip chart.The stripchart is essentially the same as the graph widget. It works almost exactly the very same way.
The use of a strip chart differs in that the X-axis typically refers to time points. Data values are added at intervals. The strip chart lets you automatically maintain a view of the most recent time points. The axis options -shiftby and -autorange control this. You can specify different line styles for data points (see the -styles option).
INTRODUCTION
The stripchart command creates a new window for plotting two-dimensional data (x,y coordinates). Data points are plotted in a box displayed in the center of the new window. This is the plotting area. The coordinate axes are displayed in the margins around the plotting area. By default, the legend is displayed in the right margin. The title is displayed in top margin.A strip chart is composed of several components: coordinate axes, data elements, legend, grid, cross hairs, pens, postscript, and annotation markers.
- axis
- The stripchart widget can display up to four coordinate axes (two X-coordinate and two Y-coordinate axes), but you can create and use any number of axes. Axes control what region of data is displayed and how the data is scaled. Each axis consists of the axis line, title, major and minor ticks, and tick labels. Tick labels display the value of each major tick.
- crosshairs
- Cross hairs are used to finely position the mouse pointer in relation to the coordinate axes. Two perpendicular lines are drawn across the plotting area, intersecting at the current location of the mouse pointer.
- element
- An element represents a set of data points. Elements can be plotted with a symbol at each data point and lines connecting the points. The appearance of the element, such as its symbol, line width, and color is configurable.
- grid
- Extends the major and minor ticks of the X-axis and/or Y-axis across the plotting area.
- legend
- The legend displays the name and symbol of each data element. The legend can be drawn in any margin or in the plotting area.
- marker
- Markers are used annotate or highlight areas of the graph. For example, you could use a polygon marker to fill an area under a curve, or a text marker to label a particular data point. Markers come in various forms: text strings, bitmaps, connected line segments, images, polygons, or embedded widgets.
- pen
- Pens define attributes (both symbol and line style) for elements. Data elements use pens to specify how they should be drawn. A data element may use many pens at once. Here, the particular pen used for a data point is determined from each element's weight vector (see the element's -weight and -style options).
- postscript
- The widget can generate encapsulated PostScript output. This component has several options to configure how the PostScript is generated.
SYNTAX
-
stripchart pathName ?option value?...
The stripchart command creates a new window pathName and makes it into a stripchart widget. At the time this command is invoked, there must not exist a window named pathName, but pathName's parent must exist. Additional options may may be specified on the command line or in the option database to configure aspects of the strip chart such as its colors and font. See the configure operation below for the exact details as to what option and value pairs are valid.
If successful, stripchart returns the path name of the widget. It also creates a new Tcl command by the same name. You can use this command to perform various operations that query or modify the graph. The general form is:
-
pathName operation ?arg?...
Both operation and its arguments determine the exact behavior of the command. The operations available for the strip chart are described in the "STRIPCHART OPERATIONS" section.
The command can also be used to access components of the strip chart.
-
pathName component operation ?arg?...
The operation, now located after the name of the component, is the function to be performed on that component. Each component has its own set of operations that manipulate that component. They will be described below in their own sections.
EXAMPLE
The stripchart command creates a new strip chart.-
# Create a new strip chart. Plotting area is black. stripchart .s -plotbackground black
A new Tcl command .s is also created. This command can be used to query and modify the strip chart. For example, to change the title of the strip chart to "My Plot", you use the new command and the widget's configure operation.
-
# Change the title. .s configure -title "My Plot"
A strip chart has several components. To access a particular component you use the component's name. For example, to add data elements, you use the new command and the element component.
-
# Create a new element named "line1" .s element create line1 \ -xdata { 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0 } \ -ydata { 26.18 50.46 72.85 93.31 111.86 128.47 143.14 155.85 166.60 175.38 }
The element's X and Y coordinates are specified using lists of numbers. Alternately, BLT vectors could be used to hold the X-Y coordinates.
-
# Create two vectors and add them to the strip chart. vector xVec yVec xVec set { 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0 } yVec set { 26.18 50.46 72.85 93.31 111.86 128.47 143.14 155.85 166.60 175.38 } .s element create line1 -xdata xVec -ydata yVec
The advantage of using vectors is that when you modify one, the graph is automatically redrawn to display the new values.
-
# Change the X-Y coordinates of the first point. set xVec(0) 0.18 set yVec(0) 25.18
An element named line1 is now created in .s. By default, the element's label in the legend will be also line1. You can change the label, or specify no legend entry, again using the element's configure operation.
-
# Don't display "line1" in the legend. .s element configure line1 -label ""
You can configure more than just the element's label. An element has many attributes such as symbol type and size, dashed or solid lines, colors, line width, etc.
-
.s element configure line1 -symbol square -color red \ -dashes { 2 4 2 } -linewidth 2 -pixels 2c
Four coordinate axes are automatically created: x, x2, y, and y2. And by default, elements are mapped onto the axes x and y. This can be changed with the -mapx and -mapy options.
-
# Map "line1" on the alternate Y-axis "y2". .s element configure line1 -mapy y2
Axes can be configured in many ways too. For example, you change the scale of the Y-axis from linear to log using the axis operation.
-
# Y-axis is log scale. .s axis configure y -logscale yes
Axis limits are reset by simply specifying new axis limits using the -min and -max configuration options.
-
.s axis configure x -min 1.0 -max 1.5 .s axis configure y -min 12.0 -max 55.15
By default, the limits of the axis are determined from data values. To reset back to the default limits, set the -min and -max options to the empty value.
-
# Reset the axes to autoscale again. .s axis configure x -min {} -max {} .s axis configure y -min {} -max {}
It's common with strip charts to automatically maintain a view of the most recent time points. You can do this my setting the -autorange option.
-
.s axis configure x -autorange 20.0
If the time points are added in X-coordinates 1.0 unit, only the last twenty time points will be displayed. As more data is added, the view will march along.
Sometimes the rate of data is so high that changing the axis limits with each additional time point is prohibitive. You can use the -shiftby option to define an increment to shift the view when needed.
-
.s axis configure x -shiftby 15.0
When the view is shifted, it will allow a range of 15 new time points to be added until the axis limits are recomputed.
By default, the legend is displayed in the right margin. You can change this or any other legend configuration options using the legend component.
-
# Configure the legend font, color, and relief .s legend configure -position left -relief raised \ -font fixed -fg blue
To prevent the legend from being displayed, turn on the -hide option.
-
# Don't display the legend. .s legend configure -hide yes
The stripchart widget has simple drawing procedures called markers. They can be used to highlight or annotate data in the strip chart. The types of markers available are bitmaps, images, polygons, lines, or windows. Markers can be used, for example, to mark or brush points. Here is a text marker which labels the data first point. Markers are created using the marker operation.
-
# Create a label for the first data point of "line1". .s marker create text -name first_marker -coords { 0.2 26.18 } \ -text "start" -anchor se -xoffset -10 -yoffset -10
This creates a text marker named first_marker. It will display the text "start" near the coordinates of the first data point. The -anchor, -xoffset, and -yoffset options are used to display the marker above and to the left of the data point, so that the actual data point isn't covered by the marker. By default, markers are drawn last, on top of data. You can change this with the -under option.
-
# Draw the label before elements are drawn. .s marker configure first_marker -under yes
You can add cross hairs or grid lines using the crosshairs and grid operations.
-
# Display both cross hairs and grid lines. .s crosshairs configure -hide no -color red .s grid configure -hide no -dashes { 2 2 }
Finally, to get hardcopy of the strip chart, use the postscript operation.
-
# Print the strip chart into file "file.ps" .s postscript output file.ps -maxpect yes -decorations no
This generates a file file.ps containing the encapsulated PostScript of the strip chart. The option -maxpect says to scale the plot to the size of the page. Turning off the -decorations option indicates that no borders or color backgrounds should be displayed (i.e. the background of the margins, legend, and plotting area will be white).
STRIPCHART OPERATIONS
- pathName axis operation ?arg?...
- See the "AXIS COMPONENTS" section.
- pathName bar elemName ?option value?...
- Creates a new barchart element elemName. It's an error if an element elemName already exists. See the manual for barchart for details about what option and value pairs are valid.
- pathName cget option
- Returns the current value of the stripchart configuration option given by option. Option may be any option described below for the configure operation.
- pathName configure ?option value?...
-
Queries or modifies the configuration options of the strip chart. If
option isn't specified, a list describing all of the current
options for pathName is returned. If option is specified,
but not value, then a list describing option is returned.
If one or more option and value pairs are specified, then
for each pair, the stripchart option option is set to value.
The following options are valid for the stripchart.
-
- -background color
- Sets the background color. This includes the margins and legend, but not the plotting area.
- -borderwidth pixels
- Sets the width of the 3-D border around the outside edge of the widget. The -relief option determines if the border is to be drawn. The default is 2.
- -bottommargin pixels
- Specifies the size of the margin below the X-coordinate axis. If pixels is 0, the size of the margin is selected automatically. The default is 0.
- -bufferelements boolean
- Indicates whether to draw elements into a pixmap before displaying them on the screen. The advantage of buffering elements is when markers are used heavily. Markers can be moved and redrawn without requiring every element to be redrawn again. The disadvantage is that it takes slightly longer to draw the graph. If boolean is true, data elements are drawn to an internal pixmap. The option should be turned off if the plot is updated frequently. See the "SPEED TIPS" section. The default is 1.
- -buffergraph boolean
- Indicates whether to draw the graph into a pixmap first. If boolean is true, the entire graph is drawn into a pixmap and then copied onto the screen. This reduces flashing. If false, the graph is drawn directly into the window. Especially under Windows, turning off the option can be helpful when the stripchart is updated frequently. Turning off this option also turns -bufferelements off. See the "SPEED TIPS" section. The default is 1.
- -cursor cursor
- Specifies the widget's cursor. The default cursor is crosshair.
- -font fontName
- Specifies the title font. The default is *-Helvetica-Bold-R-Normal-*-18-180-*.
- -halo pixels
- Specifies a maximum distance to consider when searching for the closest data point (see the element's closest operation below). Data points further than pixels away are ignored. The default is 0.5i.
- -height pixels
- Specifies the requested height of widget. The default is 4i.
- -invertxy boolean
- Indicates whether the placement X-axis and Y-axis should be inverted. If boolean is true, the X and Y axes are swapped. The default is 0.
- -justify justify
- Specifies how the title should be justified. This matters only when the title contains more than one line of text. Justify must be left, right, or center. The default is center.
- -leftmargin pixels
- Sets the size of the margin from the left edge of the window to the Y-coordinate axis. If pixels is 0, the size is calculated automatically. The default is 0.
- -plotbackground color
- Specifies the background color of the plotting area. The default is white.
- -plotborderwidth pixels
- Sets the width of the 3-D border around the plotting area. The -plotrelief option determines if a border is drawn. The default is 2.
- -plotpadx pad
- Sets the amount of padding to be added to the left and right sides of the plotting area. Pad can be a list of one or two screen distances. If pad has two elements, the left side of the plotting area entry is padded by the first distance and the right side by the second. If pad is just one distance, both the left and right sides are padded evenly. The default is 8.
- -plotpady pad
- Sets the amount of padding to be added to the top and bottom of the plotting area. Pad can be a list of one or two screen distances. If pad has two elements, the top of the plotting area is padded by the first distance and the bottom by the second. If pad is just one distance, both the top and bottom are padded evenly. The default is 8.
- -plotrelief relief
- Specifies the 3-D effect for the plotting area. Relief indicates how the interior of the plotting area should appear relative to rest of the strip chart; for example, raised means the plot should appear to protrude from the strip chart, relative to the surface of the strip chart. The default is sunken.
- -relief relief
- Specifies the 3-D effect for the widget. Relief indicates how the strip chart should appear relative to widget it is packed into; for example, raised means the strip chart should appear to protrude. The default is flat.
- -rightmargin pixels
- Sets the size of margin from the plotting area to the right edge of the window. By default, the legend is displayed in this margin. If pixels is than 1, the margin size is selected automatically.
- -takefocus focus
- Provides information used when moving the focus from window to window via keyboard traversal (e.g., Tab and Shift-Tab). If focus is 0, this means that this window should be skipped entirely during keyboard traversal. 1 means that the this window should always receive the input focus. An empty value means that the traversal scripts make the decision whether to focus on the window. The default is "".
- -tile image
- Specifies a tiled background. If image isn't "", the background is tiled using image. Otherwise, the normal background color is drawn (see the -background option). Image must be an image created using the Tk image command. The default is "".
- -title text
- Sets the title to text. If text is "", no title will be displayed.
- -topmargin pixels
- Specifies the size of the margin above the x2 axis. If pixels is 0, the margin size is calculated automatically.
- -width pixels
- Specifies the requested width of the widget. The default is 5i.
-
- pathName crosshairs operation ?arg?
- See the "CROSSHAIRS COMPONENT" section.
- pathName element operation ?arg?...
- See the "ELEMENT COMPONENTS" section.
- pathName extents item
- Returns the size of a particular item in the strip chart. Item must be either leftmargin, rightmargin, topmargin, bottommargin, plotwidth, or plotheight.
- pathName grid operation ?arg?...
- See the "GRID COMPONENT" section.
- pathName invtransform winX winY
- Performs an inverse coordinate transformation, mapping window coordinates back to graph coordinates, using the standard X-axis and Y-axis. Returns a list of containing the graph coordinates.
- pathName legend operation ?arg?...
- See the "LEGEND COMPONENT" section.
- pathName line elemName ?option value?...
- The operation is the same as element.
- pathName marker operation ?arg?...
- See the "MARKER COMPONENTS" section.
- pathName metafile ?fileName?
- This operation is for Window platforms only. Creates a Windows enhanced metafile of the stripchart. If present, fileName is the file name of the new metafile. Otherwise, the metafile is automatically added to the clipboard.
- pathName postscript operation ?arg?...
- See the "POSTSCRIPT COMPONENT" section.
- pathName snap photoName
- Takes a snapshot of the strip chart and stores the contents in the photo image photoName. PhotoName is the name of a Tk photo image that must already exist.
- pathName transform x y
- Performs a coordinate transformation, mapping graph coordinates to window coordinates, using the standard X-axis and Y-axis. Returns a list containing the X-Y screen coordinates.
- pathName xaxis operation ?arg?...
- pathName x2axis operation ?arg?...
- pathName yaxis operation ?arg?...
- pathName y2axis operation ?arg?...
- See the "AXIS COMPONENTS" section.

