stripchart(n)

๐Ÿ“ฆ version 2.5.3, in nixpkgs unstable

๐ŸŒˆ stripchart(n) ๐ŸŒˆ

okay bestie, welcome to stripchart(n) from the BLT Built-In Commands manual โ€” the page for the 2D strip chart that plots x and y coordinate data. โœจ itโ€™s giving โ€œdata but make it a vibe,โ€ and honestly the whole thing is less feral than it sounds. ๐Ÿ’…


๐ŸŒธ NAME ๐ŸŒธ

stripchart โ€” makes a 2D strip chart for plotting x and y coordinate data. ๐Ÿ’–


โœจ SYNOPSIS โœจ

stripchart pathName ?option value?...

๐Ÿ’… DESCRIPTION ๐Ÿ’…

The stripchart command creates a strip chart for plotting two-dimensional data (x,y coordinates). It has a whole bunch of configurable components: coordinate axes, elements, legend, grid lines, cross hairs, etc. โ€” and they let you customize the look and feel of the strip chart. ๐ŸŽ€

The strip chart is essentially the same as the graph widget. It works almost exactly the very same way. fr fr. ๐Ÿซถ

The way a strip chart gets used is a little different: 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 also 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 to 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 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 โœจ

Okay bestie, this is the part where it all clicks ๐Ÿ’– The stripchart command creates a new strip chart. That's it, that's the whole vibe:

# Create a new strip chart.  Plotting area is black.
stripchart .s -plotbackground black

A new Tcl command .s gets created too, which is lowkey iconic because you can use it to query and modify the strip chart. Like, say you wanna change the title to "My Plot" โ€” you just use that new command plus the widget's configure operation:

# Change the title.
.s configure -title "My Plot"

A strip chart has several components, and to get at one you use the component's name. So for adding 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 get specified as lists of numbers. Or โ€” alternate route โ€” you can use BLT vectors 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 whole point of using vectors is that when you modify one, the graph gets automatically redrawn to show the new values. Slay โœจ

# Change the X-Y coordinates of the first point.
set xVec(0) 0.18
set yVec(0) 25.18

So now there's an element named line1 in .s. By default, that element's label in the legend is also line1. You can change the label, or straight up say no legend entry, again using the element's configure operation:

# Don't display "line1" in the legend.
.s element configure line1 -label ""

And it's not just the label you can configure, bestie โ€” an element has so many attributes, like 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 get created automatically: x, x2, y, and y2 ๐Ÿ‘‘ And by default, elements are mapped onto the axes x and y. You can change that 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 tons of ways too. For example, you can 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 get reset by simply specifying new ones with 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 axis limits are determined from the data values. When you wanna go back to those 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 {}

Now here's a very strip-chart-core move: automatically keeping a view of the most recent time points. You do this by setting the -autorange option ๐Ÿ’…

.s axis configure x -autorange 20.0

If time points are added in X-coordinates 1.0 unit apart, only the last twenty time points will be displayed. As more data comes in, the view just marches along. Main character energy, honestly.

Sometimes the rate of data is so high that changing the axis limits with every single new time point is prohibitive ๐Ÿ˜ญ That's where the -shiftby option comes in โ€” it defines an increment to shift the view when needed:

.s axis configure x -shiftby 15.0

When the view is shifted, it'll allow a range of 15 new time points to be added before the axis limits get recomputed.

By default, the legend is displayed in the right margin. You can change that โ€” or any other legend configuration option โ€” using the legend component:

# Configure the legend font, color, and relief
.s legend configure -position left -relief raised \
  -font fixed -fg blue

And to stop the legend from being displayed at all, 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 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's a text marker that labels the data first point. Markers get 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

That creates a text marker named first_marker, and it'll display the text "start" near the coordinates of the first data point ๐Ÿ’– The -anchor, -xoffset, and -yoffset options are what put the marker above and to the left of the data point, so the actual data point doesn't get covered by the marker. By default, markers are drawn last, on top of the data โ€” you can flip that 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 with 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 }

And finally, to get hardcopy of the strip chart, you 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). Literally so clean โœจ

๐Ÿ’… STRIPCHART OPERATIONS ๐Ÿ’…

okay so this is the operations menu for a stripchart widget, and bestie, it is stacked. Every operation gets its own little lane, and the configure one has the whole option buffet attached. Let's go. ๐Ÿ’–

  • 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 the 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 the 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 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 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.

๐ŸŒˆ STRIPCHART COMPONENTS ๐ŸŒˆ

A strip chart is composed of several components: coordinate axes, data elements, legend, grid, cross hairs, postscript, and annotation markers. Instead of one big set of configuration options and operations, the strip chart is partitioned, where each component has its own configuration options and operations that specifically control that aspect or part of the strip chart. it's giving "organized bestie" energy, honestly. ๐Ÿซถ

๐Ÿฆ‹ AXIS COMPONENTS ๐Ÿฆ‹

Four coordinate axes are automatically created: two X-coordinate axes (x and x2) and two Y-coordinate axes (y, and y2). By default the axis x is located in the bottom margin, y in the left margin, x2 in the top margin, and y2 in the right margin.

An axis consists of the axis line, title, major and minor ticks, and tick labels. Major ticks are drawn at uniform intervals along the axis. Each tick is labeled with its coordinate value. Minor ticks are drawn at uniform intervals within major ticks. โœจ

okay so the range of the axis is literally the whole vibe check for what actually gets plotted ๐Ÿ’… โ€” it controls which region of data shows up. Any data points sitting outside the minimum and maximum limits of the axis? not plotted, not invited, not on the guest list ๐Ÿ™ˆ. By default those min and max limits get figured out from the data itself, but bestie you can absolutely reset either limit whenever you want โœจ.


You can create and use several axes at once โ€” main character energy, we love options ๐ŸŽ€. To create an axis, you invoke the axis component and its create operation:

# Create a new axis called "temperature"
.s axis create temperature

Then you map data elements onto an axis using the element's -mapy and -mapx configuration options ๐Ÿฆ‹. Those bad boys specify which coordinate axes an element is mapped onto:

# Now map the temperature data to this axis.
.s element create "temp" -xdata $x -ydata $tempData \
    -mapy temperature

So here's the tea โ˜•: you can have many axes, but only four axes can be displayed simultaneously. Fr fr. They get drawn in each of the margins surrounding the plotting area:

  • x and y are drawn in the bottom and left margins
  • x2 and y2 are drawn in the top and right margins
  • only x and y are shown by default ๐Ÿ‘‘

And lowkey the axes can have totally different scales from each other, no drama ๐ŸŒˆ.

To display a different axis, you invoke one of these components: xaxis, yaxis, x2axis, and y2axis. The use operation designates the axis to be drawn in the corresponding margin:

  • xaxis โ†’ the bottom
  • yaxis โ†’ the left
  • x2axis โ†’ the top
  • y2axis โ†’ the right
# Display the axis temperature in the left margin.
.s yaxis use temperature

You can configure axes in sooo many ways ๐Ÿงš it's giving customization icon:

  • the axis scale can be linear or logarithmic
  • the values along the axis can either monotonically increase or decrease
  • if you need custom tick labels, you can specify a Tcl procedure to format the label however you wish ๐Ÿ’–
  • you can control how ticks are drawn, by changing the major tick interval or the number of minor ticks
  • you can define non-uniform tick intervals, such as for time-series plots โญ

๐Ÿ’ซ the operations ๐Ÿ’ซ

  • pathName axis cget axisName option โ€” returns the current value of the option given by option for axisName. option may be any option described below for the axis configure operation โœจ
  • pathName axis configure axisName ?option value?... โ€” queries or modifies the configuration options of axisName ๐ŸŽ€. If option isn't specified, a list describing all the current options for axisName 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 axis option option is set to value. The following options are valid for axes ๐Ÿ‘‡
    • -autorange range โ€” sets the range of values for the axis to range. The axis limits are automatically reset to display the most recent data points in this range. If range is 0.0, the range is determined from the limits of the data. If -min or -max are specified, they override this option. The default is 0.0.
    • -color color โ€” sets the color of the axis and the tick labels. The default is black ๐Ÿ–ค
    • -command prefix โ€” specifies a Tcl command to be invoked when formatting the axis tick labels. prefix is a string containing the name of a Tcl proc and any extra arguments for the procedure. This command is invoked for each major tick on the axis. Two additional arguments are passed to the procedure: the pathname of the widget and the current numeric value of the tick. The procedure returns the formatted tick label. If "" is returned, no label will appear next to the tick ๐Ÿ™ˆ. You can get the standard tick labels again by setting prefix to "". The default is "".
โš ๏ธ bestie listen โ€” this procedure is invoked while the strip chart is redrawn. You may query the configuration options. But do not reset them, because this can have unexpected results ๐Ÿ’€ no cap.
  • -descending boolean โ€” indicates whether the values along the axis are monotonically increasing or decreasing. If boolean is true, the axis values will be decreasing. The default is 0.
  • -hide boolean โ€” indicates whether the axis is displayed ๐Ÿซฃ
  • -justify justify โ€” specifies how the axis title should be justified. This matters only when the axis title contains more than one line of text. justify must be left, right, or center. The default is center.
  • -limits formatStr โ€” specifies a printf-like description to format the minimum and maximum limits of the axis. The limits are displayed at the top/bottom or left/right sides of the plotting area. formatStr is a list of one or two format descriptions. If one description is supplied, both the minimum and maximum limits are formatted in the same way. If two, the first designates the format for the minimum limit, the second for the maximum. If "" is given as either description, then that limit will not be displayed. The default is "".
  • -linewidth pixels โ€” sets the width of the axis and tick lines. The default is 1 pixel.
  • -logscale boolean โ€” indicates whether the scale of the axis is logarithmic or linear. If boolean is true, the axis is logarithmic. The default scale is linear ๐Ÿ“
  • -loose boolean โ€” indicates whether the limits of the axis should fit the data points tightly, at the outermost data points, or loosely, at the outer tick intervals. This is relevant only when the axis limit is automatically calculated. If boolean is true, the axis range is "loose". The default is 0.
  • -majorticks majorList โ€” specifies where to display major axis ticks. You can use this option to display ticks at non-uniform intervals ๐Ÿฆ‹. majorList is a list of axis coordinates designating the location of major ticks. No minor ticks are drawn. If majorList is "", major ticks will be automatically computed. The default is "".
  • -max value โ€” sets the maximum limit of axisName. Any data point greater than value is not displayed ๐Ÿ™…โ€โ™€๏ธ. If value is "", the maximum limit is calculated using the largest data value. The default is "".
  • -min value โ€” sets the minimum limit of axisName. Any data point less than value is not displayed. If value is "", the minimum limit is calculated using the smallest data value. The default is "".
  • -minorticks minorList โ€” specifies where to display minor axis ticks. You can use this option to display minor ticks at non-uniform intervals. minorList is a list of real values, ranging from 0.0 to 1.0, designating the placement of a minor tick. No minor ticks are drawn if the -majortick option is also set. If minorList is "", minor ticks will be automatically computed. The default is "".
  • -rotate theta โ€” specifies the how many degrees to rotate the axis tick labels ๐Ÿ’ซ. theta is a real value representing the number of degrees to rotate the tick labels. The default is 0.0 degrees.
  • -shiftby value โ€” specifies how much to automatically shift the range of the axis. When the new data exceeds the current axis maximum, the maximum is increased in increments of value. You can use this option to prevent the axis limits from being recomputed at each new time point โฐ. If value is 0.0, then no automatic shifting is done. The default is 0.0.
  • -showticks boolean โ€” indicates whether axis ticks should be drawn. If boolean is true, ticks are drawn. If false, only the axis line is drawn. The default is 1.
  • -stepsize value โ€” specifies the interval between major axis ticks. If value isn't a valid interval (must be less than the axis range), the request is ignored and the step size is automatically calculated ๐Ÿ˜Œ
  • -subdivisions number โ€” indicates how many minor axis ticks are to be drawn. For example, if number is 2, only one minor tick is drawn. If number is 1, no minor ticks are displayed. The default is 2.
  • -tickfont fontName โ€” specifies the font for axis tick labels. The default is *-Courier-Bold-R-Normal-*-100-*.
  • -ticklength pixels โ€” sets the length of major and minor ticks (minor ticks are half the length of major ticks). If pixels is less than zero, the axis will be inverted, with ticks drawn pointing towards the plot ๐Ÿ”„. The default is 0.1i.
  • -title text โ€” sets the title of the axis. If text is "", no axis title will be displayed.
  • -titlecolor color โ€” sets the color of the axis title. The default is black ๐Ÿ–ค
  • -titlefont fontName โ€” specifies the font for axis title. The default is *-Helvetica-Bold-R-Normal-*-14-140-*.

Axis configuration options may also be set by the option command ๐Ÿ’…. The resource class is Axis. The resource names are the names of the axes (such as x or x2) ๐Ÿ‘‘

option add *Stripchart.Axis.Color  blue
option add *Stripchart.x.LogScale  true
option add *Stripchart.x2.LogScale false

  • pathName axis create axisName ?option value?... โ€” creates a new axis by the name axisName โœจ. No axis by the same name can already exist (sorry bestie, names are taken). option and value are described above in the axis configure operation.
  • pathName axis delete ?axisName?... โ€” deletes the named axes ๐Ÿ—‘๏ธ. An axis is not really deleted until it is no longer in use, so it's totally safe to delete axes mapped to elements ๐Ÿซถ no cap.
  • pathName axis invtransform axisName value โ€” okay so this one does the inverse transformation: it changes the screen coordinate value into a graph coordinate by mapping it to axisName. It returns the graph coordinate. ๐Ÿฆ‹
  • pathName axis limits axisName โ€” returns a list of the minimum and maximum limits for axisName. The order of the list is min max. ๐Ÿ’–
  • pathName axis names ?pattern?... โ€” returns a list of axes matching zero or more patterns. If no pattern argument is given, the names of all axes are returned. no cap.
  • pathName axis transform axisName value โ€” transforms the coordinate value to a screen coordinate by mapping it to axisName. It returns the transformed screen coordinate. โœจ

Only four axes can be displayed simultaneously. By default, they are x, y, x2, and y2. You can swap in a different axis with the use operation of the special axis components: xaxis, x2axis, yaxis, and y2axis.

.g create axis temp
.g create axis time
...
.g xaxis use temp
.g yaxis use time

Only the axes specified for use are displayed on the screen.

The xaxis, x2axis, yaxis, and y2axis components operate on an axis location rather than a specific axis like the more general axis component does. The xaxis component manages the X-axis located in the bottom margin (whatever axis that happens to be). Likewise, yaxis uses the Y-axis in the left margin, x2axis the top X-axis, and y2axis the right Y-axis.

They implicitly control the axis that is currently using that location. By default, xaxis uses the x axis, yaxis uses y, x2axis uses x2, and y2axis uses y2. These components can be more convenient to use than always determining what axes are currently being displayed by the graph.

The following operations are available for axes. They mirror exactly the operations of the axis component. The axis argument must be xaxis, x2axis, yaxis, or y2axis.

  • pathName axis cget option
  • pathName axis configure ?option value?...
  • pathName axis invtransform value
  • pathName axis limits
  • pathName axis transform value
  • pathName axis use ?axisName? โ€” designates the axis axisName to be displayed at this location. AxisName can not be already in use at another location. This command returns the name of the axis currently using this location.

๐ŸŽฏ CROSSHAIRS COMPONENT ๐ŸŽฏ

Cross hairs consist of two intersecting lines (one vertical and one horizontal) drawn completely across the plotting area. They are used to position the mouse in relation to the coordinate axes. Cross hairs differ from line markers in that they are implemented using XOR drawing primitives. This means that they can be quickly drawn and erased without redrawing the entire strip chart. fr fr, iconic.

The following operations are available for cross hairs:

  • pathName crosshairs cget option โ€” returns the current value of the cross hairs configuration option given by option. Option may be any option described below for the cross hairs configure operation.
  • pathName crosshairs configure ?option value?... โ€” queries or modifies the configuration options of the cross hairs. If option isn't specified, a list describing all the current options for the cross hairs 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 cross hairs option option is set to value. The following options are available for cross hairs.
  • -color color โ€” sets the color of the cross hairs. The default is black.
  • -dashes dashList โ€” sets the dash style of the cross hairs. DashList is a list of up to 11 numbers that alternately represent the lengths of the dashes and gaps on the cross hair lines. Each number must be between 1 and 255. If dashList is "", the cross hairs will be solid lines.
  • -hide boolean โ€” indicates whether cross hairs are drawn. If boolean is true, cross hairs are not drawn. The default is yes.
  • -linewidth pixels โ€” set the width of the cross hair lines. The default is 1.
  • -position pos โ€” specifies the screen position where the cross hairs intersect. Pos must be in the form "@x,y", where x and y are the window coordinates of the intersection.

Cross hairs configuration options may also be set by the option command. The resource name and class are crosshairs and Crosshairs respectively.

option add *Stripchart.Crosshairs.LineWidth 2
option add *Stripchart.Crosshairs.Color     red
  • pathName crosshairs off โ€” turns off the cross hairs.
  • pathName crosshairs on โ€” turns on the display of the cross hairs.
  • pathName crosshairs toggle โ€” toggles the current state of the cross hairs, alternately mapping and unmapping the cross hairs.

๐Ÿซถ ELEMENT COMPONENTS ๐Ÿซถ

A data element represents a set of data. It contains x and y vectors containing the coordinates of the data points. Elements can be displayed with a symbol at each data point and lines connecting the points. Elements also control the appearance of the data, such as the symbol type, line width, color etc. main character energy for your data, honestly.

When new data elements are created, they are automatically added to a list of displayed elements. The display list controls what elements are drawn and in what order.

The following operations are available for elements.

  • pathName element activate elemName ?index?... โ€” specifies the data points of element elemName to be drawn using active foreground and background colors. ElemName is the name of the element and index is a number representing the index of the data point. If no indices are present then all data points become active.
  • pathName element cget elemName option โ€” returns the current value of the element configuration option given by option. Option may be any option described below for the element configure operation.
  • pathName element closest x y varName ?option value?... ?elemName?... โ€” finds the data point closest to the window coordinates x and y in the element elemName. ElemName is the name of an element that must not be hidden. If no elements are specified, then all visible elements are searched. It returns via the array variable varName the name of the closest element, the index of its closest point, and the graph coordinates of the point. Returns 0 if no data point within the threshold distance can be found, otherwise 1 is returned. The following option-value pairs are available.
    • -halo pixels โ€” specifies a threshold distance where selected data points are ignored. Pixels is a valid screen distance, such as 2 or 1.2i. If this option isn't specified, then it defaults to the value of the stripchart's -halo option.
    • -interpolate boolean โ€” indicates that both the data points and interpolated points along the line segment formed should be considered. If boolean is true, the closest line segment will be selected instead of the closest point. If this option isn't specified, boolean defaults to 0.
  • pathName element configure elemName ?option value?... โ€” queries or modifies the configuration options for elements. If option isn't specified, a list describing all the current options for elemName is returned. If option is specified, but not value, then a list describing that option is returned. If one or more option and value pairs are specified, then for each pair, the element option option is set to value. The following options are valid for elements.
  • -activepen penName โ€” specifies pen to use to draw active element. If penName is "", no active elements will be drawn. The default is activeLine.
  • -color color โ€” sets the color of the traces connecting the data points.
  • -dashes dashList โ€” sets the dash style of element line. DashList is a list of up to 11 numbers that alternately represent the lengths of the dashes and gaps on the element line. Each number must be between 1 and 255. If dashList is "", the lines will be solid.
  • -data coordList โ€” specifies the X-Y coordinates of the data. CoordList is a list of numeric expressions representing the X-Y coordinate pairs of each data point.
  • -fill color โ€” sets the interior color of symbols. If color is "", then the interior of the symbol is transparent. If color is defcolor, then the color will be the same as the -color option. The default is defcolor.
  • -hide boolean โ€” indicates whether the element is displayed. The default is no.
  • -label text โ€” sets the element's label in the legend. If text is "", the element will have no entry in the legend. The default label is the element's name.
  • -linewidth pixels โ€” sets the width of the connecting lines between data points. If pixels is 0, no connecting lines will be drawn between symbols. The default is 0.
  • -mapx xAxis โ€” selects the X-axis to map the element's X-coordinates onto. XAxis must be the name of an axis. The default is x.
  • -mapy yAxis โ€” selects the Y-axis to map the element's Y-coordinates onto. YAxis must be the name of an axis. The default is y.
  • -offdash color โ€” sets the color of the stripes when traces are dashed (see the -dashes option). If color is "", then the "off" pixels will represent gaps instead of stripes. If color is defcolor, then the color will be the same as the -color option. The default is defcolor.
  • -outline color โ€” sets the color of the outline around each symbol. If color is "", then no outline is drawn. If color is defcolor, then the color will be the same as the -color option. The default is defcolor.
  • -outlinewidth pixels โ€” sets how thick the outline hugging each symbol is. Set pixels to 0 and boom, no outline at all, bestie. Default? 1. ๐ŸŽ€
  • -pixels pixels โ€” the size of your symbols. pixels of 0 means literally no symbols get drawn (yes, the default is 0.125i, not zero, don't panic ๐Ÿ’…).
  • -scalesymbols boolean โ€” okay so if boolean is true, the size of the symbols drawn for elemName actually changes with the scale of the X-axis and Y-axis. Here's the tea: at the moment you set this option, the current ranges of the axes get saved as the normalized scales (i.e. the scale factor is 1.0) and the element is drawn at its designated size (peep the -pixels option ๐Ÿ‘€). As the axes' scale changes, the symbol scales according to whichever is smaller โ€” the X-axis scale or the Y-axis scale. If boolean is false, the element's symbols are just drawn at the designated size, no matter what the axis scales are doing. Default is 0. โœจ
  • -smooth smooth โ€” controls how the connecting line segments get drawn between data points. smooth can be linear, step, natural, or quadratic.
    • linear โ†’ one single line segment connecting both data points. Clean. Simple. Iconic.
    • step โ†’ two line segments. First one is a horizontal segment that steps to the next x-coordinate, second is a vertical line moving to the next y-coordinate. It's giving staircase energy ๐Ÿชœ
    • natural and quadratic โ†’ both generate multiple segments between data points. natural builds them with a cubic spline; quadratic uses a quadratic spline.

Default is linear. ๐Ÿฆ‹

  • -styles styleList โ€” picks which pen to use based on ranges of weights. styleList is a list of style specifications, and each style specification is itself a list made of a pen name plus, optionally, a minimum and maximum range. Data points whose weight (see the -weight option) lands inside that range get drawn with that pen. If you don't give a range, it defaults to the number of the pen in the list. ๐Ÿ’–
  • -symbol symbol โ€” the symbol for your data points. symbol can be square, circle, diamond, plus, cross, splus, scross, triangle, "" (where nothing gets drawn at all), or a bitmap. Bitmaps get specified as "source ?mask?", where source is the bitmap's name and mask is the bitmap's optional mask. Default is circle. ๐Ÿ“
  • -weights wVec โ€” the weights of the individual data points. This works together with the list pen styles (see the -styles option) to control how data points are drawn. wVec is the name of a BLT vector or a list of numeric expressions representing the weight for each data point. ๐Ÿ’œ
  • -xdata xVec โ€” the x-coordinates of the data. xVec is the name of a BLT vector or a list of numeric expressions. โญ
  • -ydata yVec โ€” the y-coordinates of the data. yVec is the name of a BLT vector or a list of numeric expressions. ๐ŸŒˆ

Element configuration options can also be set with the option command, fyi. The resource class is Element, and the resource name is the name of the element. Like:

option add *Stripchart.Element.symbol line
option add *Stripchart.e1.symbol line

  • pathName element create elemName ?option value?... โ€” makes a brand new element called elemName. If an element named elemName already exists, that's an error, no cap. Any extra arguments you pass specify options valid for the element configure operation. ๐Ÿ‘‘
  • pathName element deactivate elemName ?elemName?... โ€” deactivates all the elements matching the pattern. Elements whose names match any of the patterns you gave get redrawn using their normal colors. ๐Ÿ™ˆ
  • pathName element delete ?elemName?... โ€” deletes all the named elements, and the graph gets automatically redrawn. ๐Ÿ’€
  • pathName element exists elemName โ€” returns 1 if an element named elemName currently exists, and 0 otherwise. Simple vibe check. โœ…
  • pathName element names ?pattern?... โ€” returns the elements matching one or more patterns. If you give no pattern at all, you get back the names of all the elements. ๐Ÿ“‹
  • pathName element show ?nameList? โ€” queries or modifies the element display list. The element display list decides which elements are drawn and in what order. nameList is a list of elements to be displayed in the order they're named. If there's no nameList argument, you just get the current display list back. ๐ŸŽ€
  • pathName element type elemName โ€” returns the type of elemName. If the element is a bar element, it returns the string "bar"; otherwise it returns "line". ๐Ÿฆ‹

โœจ GRID COMPONENT โœจ

Grid lines stretch out from the major and minor ticks of each axis, horizontally or vertically across the plotting area. Here's what you can do with grid lines, bestie:

  • pathName grid cget option โ€” returns the current value of the grid line configuration option given by option. option can be any option described below for the grid configure operation. ๐Ÿ‘€
  • pathName grid configure ?option value?... โ€” queries or modifies the configuration options for grid lines.
    • No option given? You get back a list describing all the current grid options for pathName.
    • option but no value? You get a list describing option.
    • One or more option and value pairs? Then for each pair, the grid line option option is set to value.

These are the valid options for grid lines:

  • -color color โ€” sets the color of the grid lines. Default is black. ๐Ÿ–ค
  • -dashes dashList โ€” sets the dash style of the grid lines. dashList is a list of up to 11 numbers that alternately represent the lengths of the dashes and gaps on the grid lines, and each number has to be between 1 and 255. If dashList is "", the grid is solid lines. โœจ
  • -hide boolean โ€” whether the grid should be drawn at all. If boolean is true, grid lines are not shown. Default is yes. ๐Ÿ™ˆ
  • -linewidth pixels โ€” sets the width of grid lines. Default width is 1. ๐Ÿ’…
  • -mapx xAxis โ€” specifies the X-axis to display grid lines on. xAxis must be the name of an axis. Default is x.
  • -mapy yAxis โ€” specifies the Y-axis to display grid lines on. yAxis must be the name of an axis. Default is y.
  • -minor boolean โ€” whether grid lines should be drawn for minor ticks. If boolean is true, the lines appear at minor tick intervals. Default is 1. ๐ŸŽ€

Grid configuration options can also be set with the option command โ€” the resource name and class are grid and Grid respectively:

option add *Stripchart.grid.LineWidth 2
option add *Stripchart.Grid.Color     black
  • pathName grid off โ€” turns off the display of the grid lines. ๐Ÿ’ค
  • pathName grid on โ€” turns on the display of the grid lines. ๐Ÿ”ฅ
  • pathName grid toggle โ€” toggles the display of the grid. Iconic, honestly. ๐Ÿซถ

๐ŸŒธ LEGEND COMPONENT ๐ŸŒธ

The legend shows off a list of the data elements, and each entry is made of the element's symbol plus its label. The legend can pop up in any margin (default location is the right margin), and it can also be positioned anywhere inside the plotting area. Main character energy, fr fr ๐Ÿ‘‘

These operations are valid for the legend:

  • pathName legend activate pattern... โ€” selects legend entries to be drawn using the active legend colors and relief. Every entry whose element name matches pattern gets selected. Heads up: to be selected, the element name only has to match one pattern. โญ
  • pathName legend cget option โ€” returns the current value of a legend configuration option. option can be any option described below in the legend configure operation. ๐Ÿ‘€
  • pathName legend configure ?option value?... โ€” queries or modifies the configuration options for the legend.
    • No option? You get a list describing the current legend options for pathName.
    • option but no value? You get a list describing option.
    • One or more option and value pairs? Each pair sets the legend option option to value.

These are the valid options for the legend:

  • -activebackground color โ€” sets the background color for active legend entries. All legend entries marked active (see the legend activate operation) get drawn using this background color. ๐ŸŽจ
  • -activeborderwidth pixels โ€” sets the width of the 3-D border around the outside edge of the active legend entries. Default is 2. โœจ
  • -activeforeground color โ€” sets the foreground color for active legend entries. All legend entries marked as active (see the legend activate operation) get drawn using this foreground color. ๐Ÿ’–
  • -activerelief relief โ€” specifies the 3-D effect you want on active legend entries. relief denotes how the interior of the entry should look relative to the legend โ€” for example, raised means the entry appears to protrude from the legend relative to the legend's surface. Default is flat. ๐Ÿซง
  • -anchor anchor โ€” tells how to position the legend relative to the positioning point for the legend. This depends on the value of the -position option. The default is center. ๐ŸŽฏ
    • left or right โ†’ the anchor describes how to position the legend vertically.
    • top or bottom โ†’ the anchor describes how to position the legend horizontally.
  • @x,y โ€” okay so anchor here is literally the vibe check for how the legend sits relative to the positioning point ๐ŸŽฏ like, if anchor is center then the legend gets centered right on the point; if anchor is n, the legend is drawn so that the top center point of the rectangular region the legend occupies lands exactly on the positioning point. positioning king behavior fr.
  • plotarea โ€” now anchor is doing the same thing but relative to the plotting area instead. So if anchor is center, the legend is centered in the plotting area; if anchor is ne, the legend is drawn so it occupies the upper right corner of the plotting area. corner-camper era ๐Ÿ’…

  • -background color โ€” sets the background color of the legend. If color is "", the legend background will be transparent (yes, it does the ghost thing ๐Ÿ‘ป).
  • -borderwidth pixels โ€” sets the width of the 3-D border around the outside edge of the legend โ€” but only if such a border is being drawn at all, and the relief option is the one deciding that, so don't come for her. the default is 2 pixels.
  • -font fontName โ€” FontName is the font used when drawing the labels of each element into the legend. the default is *-Helvetica-Bold-R-Normal-*-12-120-*.
  • -foreground color โ€” sets the foreground color of the text drawn for the element's label. the default is black.
  • -hide boolean โ€” says whether the legend should be displayed at all. if boolean is true, the legend will not be draw [sic, she's a little goofy but we love her]. the default is no.
  • -ipadx pad โ€” sets the amount of internal padding added to the width of each legend entry. Pad can be a list of one or two screen distances. if pad has two elements, the left side of the legend entry is padded by the first distance and the right side by the second. if pad is just one distance, both left and right get padded evenly. the default is 2.
  • -ipady pad โ€” same iconique energy but for the height of each legend entry. Pad can be a list of one or two screen distances. if pad has two elements, the top of the entry is padded by the first distance and the bottom by the second. if pad is just one distance, top and bottom get padded evenly. the default is 2.
  • -padx pad โ€” sets the padding on the left and right exteriors of the legend ๐Ÿซถ Pad can be a list of one or two screen distances. two elements โ†’ left side padded by the first distance, right side by the second. one distance โ†’ both sides evenly. the default is 4.
  • -pady pad โ€” padding above and below the legend. Pad can be a list of one or two screen distances. two elements โ†’ area above padded by the first distance, area below by the second. one distance โ†’ top and bottom padded evenly. the default is 0.
  • -position pos โ€” specifies where the legend is drawn, and the -anchor option also affects how it's positioned, so these two are in their duo era โœจ if pos is left, left, top, or bottom, the legend is drawn in the specified margin. if pos is plotarea, then the legend is drawn inside the plotting area at a particular anchor. if pos is in the form "@x,y", where x and y are the window coordinates, the legend is drawn in the plotting area at those specified coordinates. the default is right.
  • -raised boolean โ€” indicates whether the legend sits above or below the data elements. this only matters if the legend is in the plotting area, okay? if boolean is true, the legend will be drawn on top of any elements that may overlap it. the default is no.
  • -relief relief โ€” specifies the 3-D effect for the border around the legend. Relief says how the interior of the legend should appear relative to the strip chart โ€” for example, raised means the legend should appear to protrude from the strip chart, relative to the surface of the strip chart. the default is sunken.

Legend configuration options may also be set by the option command. the resource name and class are legend and Legend respectively. so like:

option add *Stripchart.legend.Foreground blue
option add *Stripchart.Legend.Relief     raised

pathName legend deactivate pattern...

Selects legend entries to be drawn using the normal legend colors and relief. every entry whose element name matches pattern gets selected. to be selected, the element name has to match only one pattern โ€” no double-dipping bestie ๐Ÿ™ˆ

pathName legend get pos

Returns the name of the element whose entry is at the screen position pos in the legend. Pos must be in the form "@x,y", where x and y are window coordinates. if the given coordinates don't lie over a legend entry, "" is returned. she said no entry no name ๐Ÿ’€


โœจ PEN COMPONENTS โœจ

okay so pens define attributes โ€” both symbol and line style โ€” for elements. pens literally mirror the configuration options of data elements that pertain to how symbols and lines are drawn. data elements use pens to determine how they're drawn ๐Ÿ–Š๏ธ and a data element may use several pens at once. in that case, the pen used for a particular data point is determined from each element's weight vector โ€” see the element's -weight and -style options for the receipts.

one pen, called activeLine, is automatically created. it's used as the default active pen for elements. so you can change the active attributes for all elements by simply reconfiguring this one pen. main character pen behavior fr ๐Ÿ‘‘

.s pen configure "activeLine" -color green

you can create and use any number of pens. to create a pen, invoke the pen component and its create operation.

.s pen create myPen

you map pens to a data element using either the element's -pen or -activepen options ๐Ÿ’–

.s element create "line1" -xdata $x -ydata $tempData \
    -pen myPen

and an element can use several pens at once โ€” you do this by specifying the name of the pen in the element's style list (see the -styles option):

.s element configure "line1" -styles { myPen 2.0 3.0 }

this says that any data point with a weight between 2.0 and 3.0 is to be drawn using the pen myPen. all other points are drawn with the element's default attributes. selective slay โœจ

the following operations are available for pen components.

pathName pen cget penName option

Returns the current value of the option given by option for penName. Option may be any option described below for the pen configure operation.

pathName pen configure penName ?option value?...

Queries or modifies the configuration options of penName. if option isn't specified, a list describing the current options for penName 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 pen option option is set to value. the following options are valid for pens ๐ŸŒธ

  • -color color โ€” sets the color of the traces connecting the data points.
  • -dashes dashList โ€” sets the dash style of element line. DashList is a list of up to 11 numbers that alternately represent the lengths of the dashes and gaps on the element line. each number must be between 1 and 255. if dashList is "", the lines will be solid.
  • -fill color โ€” sets the interior color of symbols. if color is "", then the interior of the symbol is transparent. if color is defcolor, then the color will be the same as the -color option. the default is defcolor.
  • -linewidth pixels โ€” sets the width of the connecting lines between data points. if pixels is 0, no connecting lines will be drawn between symbols. the default is 0.
  • -offdash color โ€” sets the color of the stripes when traces are dashed (see the -dashes option). if color is "", then the "off" pixels will represent gaps instead of stripes. if color is defcolor, then the color will be the same as the -color option. the default is defcolor.
  • -outline color โ€” sets the color or the outline around each symbol. if color is "", then no outline is drawn. if color is defcolor, then the color will be the same as the -color option. the default is defcolor.
  • -outlinewidth pixels โ€” sets the width of the outline bordering each symbol. if pixels is 0, no outline will be drawn. the default is 1.
  • -pixels pixels โ€” sets the size of symbols. if pixels is 0, no symbols will be drawn. the default is 0.125i.
  • -symbol symbol โ€” specifies the symbol for data points. Symbol can be either square, circle, diamond, plus, cross, splus, scross, triangle, "" (where no symbol is drawn), or a bitmap. bitmaps are specified as "source ?mask?", where source is the name of the bitmap and mask is the bitmap's optional mask. the default is circle โญ•
  • -type elemType โ€” specifies the type of element the pen is to be used with. this option should only be employed when creating the pen. it's for those that wish to mix different types of elements (bars and lines) on the same graph. the default type is "line".

Pen configuration options can also be set by the option command, bestie ๐Ÿ’…. The resource class is Pen. The resource names are literally the names of the pens. Like this:

option add *Stripchart.Pen.Color  blue
option add *Stripchart.activeLine.color  green
  • pathName pen create penName ?option value?... โ€” Creates a new pen named penName. No pen with that same name can already exist. option and value are described above in the pen configure operation.
  • pathName pen delete ?penName?... โ€” Deletes the named pens. A pen isnโ€™t really deleted until itโ€™s no longer in use, so itโ€™s safe to delete pens mapped to elements ๐Ÿซถ.
  • pathName pen names ?pattern?... โ€” Returns a list of pens matching zero or more patterns. If you donโ€™t give a pattern argument, the names of all pens are returned.

๐ŸŒˆ POSTSCRIPT COMPONENT ๐ŸŒˆ

The strip chart can generate encapsulated PostScript output, and there are several configuration options you can specify to control how the plot is generated. You can change the page dimensions and borders. The plot itself can be scaled, centered, or rotated to landscape. The PostScript output can be written directly to a file or returned through the interpreter โœจ.

The following postscript operations are available:

  • pathName postscript cget option โ€” Returns the current value of the postscript option given by option. option may be any option described below for the postscript configure operation.
  • pathName postscript configure ?option value?... โ€” Queries or modifies the configuration options for PostScript generation. If option isnโ€™t specified, a list describing the current postscript 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 postscript option option is set to value.

The following postscript options are available, no cap:

  • -center boolean โ€” Indicates whether the plot should be centered on the PostScript page. If boolean is false, the plot will be placed in the upper left corner of the page. The default is 1.
  • -colormap varName โ€” varName must be the name of a global array variable that specifies a color mapping from the X color name to PostScript. Each element of varName must consist of PostScript code to set a particular color value (e.g. 1.0 1.0 0.0 setrgbcolor). When outputting color information in PostScript, the array variable varName is checked to see if an element of the name of the color exists. If so, it uses the value of the element as the PostScript command to set the color. If this option hasnโ€™t been specified, or if there isnโ€™t an entry in varName for a given color, then it uses the red, green, and blue intensities from the X color.
  • -colormode mode โ€” Specifies how to output color information. mode must be either color (for full color output), gray (convert all colors to their gray-scale equivalents) or mono (convert foreground colors to black and background colors to white). The default mode is color.
  • -fontmap varName โ€” varName must be the name of a global array variable that specifies a font mapping from the X font name to PostScript. Each element of varName must consist of a Tcl list with one or two elements, which are the name and point size of a PostScript font. When outputting PostScript commands for a particular font, the array variable varName is checked to see an element of the specified font exists. If there is such an element, then the font information contained in that element is used in the PostScript output. (If the point size is omitted from the list, the point size of the X font is used). Otherwise the X font is examined in an attempt to guess what PostScript font to use. This works only for fonts whose foundry property is Adobe (such as Times, Helvetica, Courier, etc.). If all of this fails then the font defaults to Helvetica-Bold.
  • -decorations boolean โ€” Indicates if PostScript commands to generate color backgrounds and 3-D borders should be output. If boolean is false, the background will be white and no 3-D borders will be generated. The default is 1.
  • -height pixels โ€” Sets the height of the plot. This lets you plot the stripchart with a height different from the one displayed on the screen. If pixels is 0, the height is the same as the displayed height. The default is 0.
  • -landscape boolean โ€” If boolean is true, this specifies the printed area is to be rotated 90 degrees. In non-rotated output the X-axis of the printed area runs along the short dimension of the page (portrait orientation); in rotated output the X-axis runs along the long dimension of the page (landscape orientation). Defaults to 0.
  • -maxpect boolean โ€” Indicates to scale the plot so that it fills the PostScript page. The aspect ratio of the strip chart is still retained. The default is 0.
  • -padx pad โ€” Sets the horizontal padding for the left and right page borders. The borders are exterior to the plot. pad can be a list of one or two screen distances. If pad has two elements, the left border is padded by the first distance and the right border by the second. If pad has just one distance, both the left and right borders are padded evenly. The default is 1i.
  • -pady pad โ€” Sets the vertical padding for the top and bottom page borders. The borders are exterior to the plot. pad can be a list of one or two screen distances. If pad has two elements, the top border is padded by the first distance and the bottom border by the second. If pad has just one distance, both the top and bottom borders are padded evenly. The default is 1i.
  • -paperheight pixels โ€” Sets the height of the postscript page. This can be used to select between different page sizes (letter, A4, etc). The default height is 11.0i.
  • -paperwidth pixels โ€” Sets the width of the postscript page. This can be used to select between different page sizes (letter, A4, etc). The default width is 8.5i.
  • -width pixels โ€” Sets the width of the plot. This lets you plot the strip chart with a width different from the one drawn on the screen. If pixels is 0, the width is the same as the widgetโ€™s width. The default is 0.

Postscript configuration options can also be set by the option command. The resource name and class are postscript and Postscript respectively. iykyk ๐ŸŽ€

option add *Stripchart.postscript.Decorations false
option add *Stripchart.Postscript.Landscape   true
  • pathName postscript output ?fileName? ?option value?... โ€” Outputs a file of encapsulated PostScript. If a fileName argument isnโ€™t present, the command returns the PostScript. If any option-value pairs are present, they set configuration options controlling how the PostScript is generated. option and value can be anything accepted by the postscript configure operation above.

๐ŸŽ€ MARKER COMPONENTS ๐ŸŽ€

Markers are simple drawing procedures used to annotate or highlight areas of the strip chart. Markers have various types: text strings, bitmaps, images, connected lines, windows, or polygons. They can be associated with a particular element, so that when the element is hidden or un-hidden, so is the marker. By default, markers are the last items drawn, so that data elements will appear behind them. You can change this by configuring the -under option.

Markers, in contrast to elements, donโ€™t affect the scaling of the coordinate axes. They can also have elastic coordinates (specified by -Inf and Inf respectively) that translate into the minimum or maximum limit of the axis. For example, you can place a marker so it always remains in the lower left corner of the plotting area, by using the coordinates -Inf,-Inf ๐Ÿ’–.

The following operations are available for markers:

  • pathName marker after markerId ?afterId? โ€” Changes the order of the markers, drawing the first marker after the second. If no second afterId argument is specified, the marker is placed at the end of the display list. This command can be used to control how markers are displayed since markers are drawn in the order of this display list.
  • pathName marker before markerId ?beforeId? โ€” Changes the order of the markers, drawing the first marker before the second. If no second beforeId argument is specified, the marker is placed at the beginning of the display list. This command can be used to control how markers are displayed since markers are drawn in the order of this display list.
  • pathName marker cget option โ€” Returns the current value of the marker configuration option given by option. option may be any option described below in the configure operation.
  • pathName marker configure markerId ?option value?... โ€” Queries or modifies the configuration options for markers. If option isnโ€™t specified, a list describing the current options for markerId 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 marker option option is set to value.

The following options are valid for all markers. Each type of marker also has its own type-specific options. They are described in the sections below ๐Ÿฆ‹.

  • -coords coordList โ€” okay so this one tells the marker where to sit. coordList is a list of graph coordinates. How many coordinates you need depends on the marker type: text, image, and window markers need only two coordinates (an X-Y coordinate) ๐Ÿ’…. Bitmap markers can take either two or four coordinates (if four, they represent the corners of the bitmap). Line markers need at least four coordinates, polygons at least six. If coordList is "", the marker will not be displayed. The default is "".
  • -element elemName โ€” links the marker with the element elemName. The marker is drawn only if the element is also currently displayed (see the element's show operation). If elemName is "", the marker is always drawn. The default is "".
  • -hide boolean โ€” indicates whether the marker is drawn. If boolean is true, the marker is not drawn. The default is no. (yes bestie, true means hidden โ€” it's giving gremlin logic ๐Ÿ™ˆ)
  • -mapx xAxis โ€” specifies the X-axis to map the marker's X-coordinates onto. xAxis must be the name of an axis. The default is x.
  • -mapy yAxis โ€” specifies the Y-axis to map the marker's Y-coordinates onto. yAxis must be the name of an axis. The default is y.
  • -name markerId โ€” changes the identifier for the marker. The identifier markerId can not already be used by another marker. If this option isn't specified, the marker's name is uniquely generated.
  • -under boolean โ€” indicates whether the marker is drawn below/above data elements. If boolean is true, the marker is drawn underneath the data element symbols and lines. Otherwise, the marker is drawn on top of the element. The default is 0.
  • -xoffset pixels โ€” specifies a screen distance to offset the marker horizontally. pixels is a valid screen distance, such as 2 or 1.2i. The default is 0.
  • -yoffset pixels โ€” specifies a screen distance to offset the markers vertically. pixels is a valid screen distance, such as 2 or 1.2i. The default is 0.

Also marker configuration options may also be set by the option command. The resource class is either BitmapMarker, ImageMarker, LineMarker, PolygonMarker, TextMarker, or WindowMarker, depending on the type of marker. The resource name is the name of the marker.

option add *Stripchart.TextMarker.Foreground white
option add *Stripchart.BitmapMarker.Foreground white
option add *Stripchart.m1.Background     blue
  • pathName marker create type ?option value?... โ€” creates a marker of the selected type. type may be either text, line, bitmap, image, polygon, or window. This command returns the marker identifier, used as the markerId argument in the other marker-related commands. If the -name option is used, this overrides the normal marker identifier. If the name provided is already used for another marker, the new marker will replace the old.
  • pathName marker delete ?name?... โ€” removes one or more markers. The graph will automatically be redrawn without the marker.
  • pathName marker exists markerId โ€” returns 1 if the marker markerId exists and 0 otherwise.
  • pathName marker names ?pattern? โ€” returns the names of all the markers that currently exist. If pattern is supplied, only those markers whose names match it will be returned.
  • pathName marker type markerId โ€” returns the type of the marker given by markerId, such as line or text. If markerId is not a valid marker identifier, "" is returned.

๐Ÿ–ผ๏ธ BITMAP MARKERS ๐Ÿ–ผ๏ธ

A bitmap marker displays a bitmap. The size of the bitmap is controlled by the number of coordinates specified. If two coordinates, they specify the position of the top-left corner of the bitmap. The bitmap retains its normal width and height. If four coordinates, the first and second pairs of coordinates represent the corners of the bitmap. The bitmap will be stretched or reduced as necessary to fit into the bounding rectangle. slay.

Bitmap markers are created with the marker's create operation in the form: pathName marker create bitmap ?option value?.... There may be many option-value pairs, each sets a configuration option for the marker. These same option-value pairs may be used with the marker's configure operation.

The following options are specific to bitmap markers:

  • -background color โ€” sets the background color of the bitmap. If color is "", the background color will be transparent. The default background color is white.
  • -bitmap bitmap โ€” specifies the bitmap to be displayed. If bitmap is "", the marker will not be displayed. The default is "".
  • -foreground color โ€” sets the foreground color of the bitmap. The default foreground color is black.
  • -mask mask โ€” specifies a mask for the bitmap to be displayed. This mask is a bitmap itself, denoting the pixels that are transparent. If mask is "", all pixels of the bitmap will be drawn. The default is "".
  • -rotate theta โ€” sets the rotation of the bitmap. theta is a real number representing the angle of rotation in degrees. The marker is first rotated and then placed according to its anchor position. The default rotation is 0.0.

๐ŸŒธ IMAGE MARKERS ๐ŸŒธ

An image marker displays an image. Image markers are created with the marker's create operation in the form: pathName marker create image ?option value?.... There may be many option-value pairs, each sets a configuration option for the marker. These same option-value pairs may be used with the marker's configure operation.

The following options are specific to image markers:

  • -anchor anchor โ€” anchor tells how to position the image relative to the positioning point for the image. For example, if anchor is center then the image is centered on the point; if anchor is n then the image will be drawn such that the top center point of the rectangular region occupied by the image will be at the positioning point. This option defaults to center.
  • -image image โ€” specifies the image to be drawn. If image is "", the marker will not be drawn. The default is "".

๐Ÿ“ˆ LINE MARKERS ๐Ÿ“ˆ

A line marker displays one or more connected line segments. Line markers are created with marker's create operation in the form: pathName marker create line ?option value?.... There may be many option-value pairs, each sets a configuration option for the marker. These same option-value pairs may be used with the marker's configure operation.

The following options are specific to line markers:

  • -background color โ€” sets the background color of the line. This option only affects the line color when the -stipple option is set. If this option isn't specified then it defaults to white.
  • -dashes dashList โ€” sets the dash style of the line. dashList is a list of up to 11 numbers that alternately represent the lengths of the dashes and gaps on the line. Each number must be between 1 and 255. If dashList is "", the marker line will be solid.
  • -foreground color โ€” sets the foreground color. The default foreground color is black.
  • -linewidth pixels โ€” sets the width of the lines. The default width is 0.
  • -stipple bitmap โ€” specifies a stipple pattern used to draw the line, rather than a solid line. bitmap specifies a bitmap to use as the stipple pattern. If bitmap is "", then the line is drawn in a solid fashion. The default is "".

๐Ÿ”ท POLYGON MARKERS ๐Ÿ”ท

A polygon marker displays a closed region described as two or more connected line segments. It is assumed the first and last points are connected. Polygon markers are created using the marker create operation in the form: pathName marker create polygon ?option value?.... There may be many option-value pairs, each sets a configuration option for the marker. These same option-value pairs may be used with the marker configure command to change the marker's configuration. The following options are supported for polygon markers:

  • -dashes dashList โ€” sets the dash style of the outline of the polygon. dashList is a list of up to 11 numbers that alternately represent the lengths of the dashes and gaps on the outline. Each number must be between 1 and 255. If dashList is "", the outline will be a solid line.
  • -fill color โ€” sets the fill color of the polygon. If color is "", then the interior of the polygon is transparent. The default is white.
  • -linewidth pixels โ€” sets the width of the outline of the polygon. If pixels is zero, no outline is drawn. The default is 0.
  • -outline color โ€” sets the color of the outline of the polygon. If the polygon is stippled (see the -stipple option), then this represents the foreground color of the stipple. The default is black.
  • -stipple bitmap โ€” specifies that the polygon should be drawn with a stippled pattern rather than a solid color. bitmap specifies a bitmap to use as the stipple pattern. If bitmap is "", then the polygon is filled with a solid color (if the -fill option is set). The default is "".

๐Ÿ’ฌ TEXT MARKERS ๐Ÿ’ฌ

A text marker displays a string of characters on one or more lines of text. Embedded newlines cause line breaks. They may be used to annotate regions of the strip chart. Text markers are created with the create operation in the form: pathName marker create text ?option value?.... There may be many option-value pairs, each sets a configuration option for the text marker. These same option-value pairs may be used with the marker's configure operation.

The following options are specific to text markers:

  • -anchor anchor โ€” anchor tells how to position the text relative to the positioning point for the text. For example, if anchor is center then the text is centered on the point; if anchor is n then the text will be drawn such that the top center point of the rectangular region occupied by the text will be at the positioning point. This default is center.
  • -background color โ€” sets the background color of the text string, bestie. If color is "", the background will be transparent. The default is white ๐Ÿ’…
  • -font fontName โ€” specifies the font of the text. The default is *-Helvetica-Bold-R-Normal-*-120-* โœจ
  • -foreground color โ€” sets the foreground color of the text. The default is black ๐Ÿ–ค
  • -justify justify โ€” specifies how the text should be justified. This matters only when the marker contains more than one line of text. justify must be left, right, or center. The default is center ๐ŸŽ€
  • -padx pad โ€” sets the padding to the left and right exteriors of the text. pad can be a list of one or two screen distances. If pad has two elements, the left side of the text is padded by the first distance and the right side by the second. If pad has just one distance, both the left and right sides are padded evenly. The default is 4 ๐Ÿ’–
  • -pady pad โ€” sets the padding above and below the text. pad can be a list of one or two screen distances. If pad has two elements, the area above the text is padded by the first distance and the area below by the second. If pad is just one distance, both the top and bottom areas are padded evenly. The default is 4 ๐Ÿ’–
  • -rotate theta โ€” specifies the number of degrees to rotate the text. theta is a real number representing the angle of rotation. The marker is first rotated along its center and is then drawn according to its anchor position. The default is 0.0 ๐ŸŒ€
  • -text text โ€” specifies the text of the marker. The exact way the text is displayed may be affected by other options such as -anchor or -rotate โœจ

๐ŸชŸ WINDOW MARKERS ๐ŸชŸ

A window marker displays a widget at a given position. Window markers are created with the marker's create operation in the form:

pathName marker create window ?option value?...

There may be many option/value pairs, each sets a configuration option for the marker. These same option-value pairs may be used with the marker's configure command ๐Ÿ‘‘

The following options are specific to window markers:

  • -anchor anchor โ€” tells how to position the widget relative to the positioning point for the widget. For example, if anchor is center, then the widget is centered on the point; if anchor is n, then the widget will be displayed such that the top center point of the rectangular region occupied by the widget will be at the positioning point. This option defaults to center ๐Ÿ“Œ
  • -height pixels โ€” specifies the height to assign to the marker's window. If this option isn't specified, or if it is specified as "", then the window is given whatever height the widget requests internally ๐Ÿ“
  • -width pixels โ€” specifies the width to assign to the marker's window. If this option isn't specified, or if it is specified as "", then the window is given whatever width the widget requests internally ๐Ÿ“
  • -window pathName โ€” specifies the widget to be managed. pathName must be a child of the stripchart widget ๐Ÿซถ

๐Ÿ”— GRAPH COMPONENT BINDINGS ๐Ÿ”—

Specific stripchart components โ€” such as elements, markers, and legend entries โ€” can have a command trigger when an event occurs in them, much like canvas items in Tk's canvas widget. Not all event sequences are valid, no cap. The only binding events that may be specified are those related to the mouse and keyboard (such as Enter, Leave, ButtonPress, Motion, and KeyPress) ๐Ÿ–ฑ๏ธโŒจ๏ธ

Only one element or marker can be picked during an event. This means that if the mouse is directly over both an element and a marker, only the uppermost component is selected. This isn't true for legend entries. Both a legend entry and an element (or marker) binding commands will be invoked if both items are picked ๐Ÿ‘‘

It is possible for multiple bindings to match a particular event. This could occur, for example, if one binding is associated with the element name and another is associated with one of the element's tags (see the -bindtags option). When this occurs, all of the matching bindings are invoked. A binding associated with the element name is invoked first, followed by one binding for each of the element's bindtags. If there are multiple matching bindings for a single tag, then only the most specific binding is invoked. A continue command in a binding script terminates that script, and a break command terminates that script and skips any remaining scripts for the event, just as for the bind command ๐Ÿ’…

The -bindtags option for these components controls additional tag names that can be matched. Implicitly elements and markers always have tags matching their names. Setting the value of the -bindtags option doesn't change this ๐Ÿท๏ธ


๐Ÿง‘โ€๐Ÿ’ป C LANGUAGE API ๐Ÿง‘โ€๐Ÿ’ป

You can manipulate data elements straight from the C language. There may be situations where it is too expensive to translate the data values from ASCII strings. Or you might want to read data in a special file format ๐Ÿ‘€

Data can be manipulated from C using BLT vectors. You specify the x and y data coordinates of an element as vectors and manipulate the vector from C. The strip chart will be redrawn automatically after the vectors are updated โœจ

From Tcl, create the vectors and configure the element to use them:

vector X Y
.s element configure line1 -xdata X -ydata Y

To set data points from C, you pass the values as arrays of doubles using the Blt_ResetVector call. The vector is reset with the new data and at the next idle point (when Tk re-enters its event loop), the strip chart will be redrawn automatically ๐Ÿ”

#include <tcl.h>
#include <blt.h>

register int i;
Blt_Vector *xVec, *yVec;
double x[50], y[50];

/* Get the BLT vectors "X" and "Y" (created above from Tcl) */
if ((Blt_GetVector(interp, "X", 50, &xVec) != TCL_OK) ||
    (Blt_GetVector(interp, "Y", 50, &yVec) != TCL_OK)) {
    return TCL_ERROR;
}

for (i = 0; i < 50; i++) {
    x[i] = i * 0.02;
    y[i] = sin(x[i]);
}

/* Put the data into BLT vectors */
if ((Blt_ResetVector(xVec, x, 50, 50, TCL_VOLATILE) != TCL_OK) ||
    (Blt_ResetVector(yVec, y, 50, 50, TCL_VOLATILE) != TCL_OK)) {
   return TCL_ERROR;
}

See the vector manual page for more details ๐Ÿ“–


โšก SPEED TIPS โšก

There may be cases where the strip chart needs to be drawn and updated as quickly as possible. If drawing speed becomes a big problem, here are a few tips to speed up displays:

  • Try to minimize the number of data points. The more data points that get looked at, the more work the strip chart must do ๐Ÿƒโ€โ™€๏ธ
  • If your data is generated as floating point values, the time required to convert the data values to and from ASCII strings can be significant, especially when there are many data points. You can avoid the redundant string-to-decimal conversions using the C API to BLT vectors ๐Ÿ”ข
  • Data elements without symbols are drawn faster than with symbols. Set the data element's -symbol option to none. If you need to draw symbols, try using the simple symbols such as splus and scross โญ
  • Don't stipple or dash the element. Solid lines are much faster ๐Ÿš€
  • If you update data elements frequently, try turning off the widget's -bufferelements option. When the strip chart is first displayed, it draws data elements into an internal pixmap. The pixmap acts as a cache, so that when the strip chart needs to be redrawn again, and the data elements or coordinate axes haven't changed, the pixmap is simply copied to the screen. This is especially useful when you are using markers to highlight points and regions on the strip chart. But if the strip chart is updated frequently, changing either the element data or coordinate axes, the buffering becomes redundant ๐Ÿ’พ

๐Ÿšง LIMITATIONS ๐Ÿšง

Auto-scale routines do not use requested min/max limits as boundaries when the axis is logarithmically scaled ๐Ÿ“‰

The PostScript output generated for polygons with more than 1500 points may exceed the limits of some printers (See PostScript Language Reference Manual, page 568). The work-around is to break the polygon into separate pieces ๐Ÿ–จ๏ธ


๐Ÿ”ฎ FUTURE INCOMPATIBILITY ๐Ÿ”ฎ

The -mapped options are obsoleted and will be removed. You can achieve the same results using the -hide option instead โš ๏ธ
# Works for now.
.s legend configure -mapped no
# Instead use this.
.s legend configure -hide yes

๐Ÿท๏ธ KEYWORDS ๐Ÿท๏ธ

stripchart, graph, widget โ€” iykyk ๐Ÿ’œ


Source/version check: BLT 2.5, page stripchart(n). The date wasnโ€™t printed in the footer, so Iโ€™m not inventing one โ€” periodt ๐Ÿ’…๐Ÿซถ

๐Ÿ“ฆ where this page comes from
  • nixpkgs unstable: blt 2.5.3
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms