blt::stripchart(3tcl)
π blt::stripchart β the BLT Built-In Commands glow-up π
okay bestie, sit DOWN because we're about to talk about blt::stripchart(3tcl), the BLT Built-In Command that plots your x and y coordinate data and honestly? it's giving main character energy π
β¨ NAME β¨
stripchart β a 2D strip chart for plotting x and y coordinate data. periodt. π¦
πΈ SYNOPSIS πΈ
stripchart pathName ?option value?...
π DESCRIPTION π
The stripchart command creates a strip chart for plotting two-dimensional data (x,y coordinates). It has SO many configurable components, like coordinate axes, elements, legend, grid lines, cross hairs, etc. and they all let you customize the look and feel of your strip chart. obsessed. π₯
The stripchart is essentially the same as the graph widget. It works almost exactly the very same way. literally twins. π―
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). slay. β¨
π 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. cute layout, no notes. π
A strip chart is composed of several components: coordinate axes, data elements, legend, grid, cross hairs, pens, postscript, and annotation markers. let's meet the cast π«Ά
- 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. so precise. π―
- 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. glow-up central. π
- grid β Extends the major and minor ticks of the X-axis and/or Y-axis across the plotting area. structure? we love her. π
- 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. she can go ANYWHERE. π
- 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. so versatile it's unreal. π¦
- 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
-weightand-styleoptions). iykyk. ποΈ - postscript β The widget can generate encapsulated PostScript output. This component has several options to configure how the PostScript is generated. fancy export moment. π
π¦ 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. π
ok bestie that's the setup, more parts are coming so don't go anywhere πβ¨
π EXAMPLE π
Okay bestie, this is the part where it all clicks. Watch the stripchart command do its thing β it makes you a brand new strip chart. Periodt.
# Create a new strip chart. Plotting area is black.
stripchart .s -plotbackground black
A new Tcl command .s also gets created, and it's your command now β you use it to query and modify the strip chart. So say you wanna rename the title to "My Plot"? You just call that new command with the widget's configure operation. Main character behavior.
# Change the title.
.s configure -title "My Plot"
A strip chart is built out of several components, and you reach a particular one by its name. Wanna add data elements? Use the new command plus the element component. Easy.
# 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 go in as lists of numbers. But wait β you can also hand it BLT vectors to hold the X-Y coordinates instead. And that's lowkey the better move.
# 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 glow-up of using vectors? When you modify one, the graph automatically redraws to show the new values. No manual refresh, no drama. Obsessed.
# Change the X-Y coordinates of the first point.
set xVec(0) 0.18
set yVec(0) 25.18
An element named line1 now exists in .s. And by default its label in the legend is also line1. You can change that label, or straight up say "no legend entry for you," again using the element's configure operation.
# Don't display "line1" in the legend.
.s element configure line1 -label ""
But bestie, you can configure so much more than just the label. An element has a whole wardrobe of attributes: symbol type and size, dashed or solid lines, colors, line width, etc. Serve.
.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. Wanna switch that up? That's what the -mapx and -mapy options are for.
# 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 flip 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 just by 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
And by default, the limits of an axis are figured out from your data values. Wanna go back to that default? Set -min and -max to the empty value. Reset era.
# Reset the axes to autoscale again.
.s axis configure x -min {} -max {}
.s axis configure y -min {} -max {}
Now here's a super common strip chart mood: automatically keeping a view of the most recent time points. You do that by setting the -autorange option.
.s axis configure x -autorange 20.0
If the time points get added in X-coordinates of 1.0 unit, then only the last twenty time points will be displayed. And as more data gets added, the view just marches along. Iconic.
But sometimes the data rate is so high that changing the axis limits with every single additional time point is prohibitive. That's where -shiftby 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 until the axis limits get recomputed. Chef's kiss.
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 also has simple drawing procedures called markers. They're for highlighting or annotating data in the strip chart. The types of markers available are bitmaps, images, polygons, lines, or windows. You can use markers to, like, mark or brush points. Here's a text marker that labels the first data 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. It'll display the text "start" near the coordinates of the first data point. The -anchor, -xoffset, and -yoffset options are what push the marker above and to the left of the data point, so the actual data point doesn't get covered by the marker. So considerate π
.
And 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 -maxpect option says to scale the plot to the size of the page. And turning off the -decorations option means no borders or color backgrounds should be displayed β i.e. the background of the margins, legend, and plotting area will be white. Clean aesthetic, no cap.
π STRIPCHART OPERATIONS π
okay bestie, this is the part where the stripchart actually does stuff. Every operation hangs off pathName, and here's the whole menu. π
pathName axis operation ?arg?...β See the AXIS COMPONENTS section. It's giving axis energy. π¦pathName bar elemName ?option value?...β Creates a new barchart elementelemName. It's an error if an elementelemNamealready exists. See the manual for barchart for details about whatoptionandvaluepairs are valid. πpathName cget optionβ Returns the current value of the stripchart configuration option given byoption.Optionmay be any option described below for theconfigureoperation. β¨pathName configure ?option value?...β Queries or modifies the configuration options of the strip chart. Ifoptionisn't specified, a list describing all of the current options forpathNameis returned. Ifoptionis specified, but notvalue, then a list describingoptionis returned. If one or moreoptionandvaluepairs are specified, then for each pair, the stripchart optionoptionis set tovalue. The following options are valid for the stripchart. π
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-reliefoption determines if the border is to be drawn. The default is2. π-bottommargin pixelsβ Specifies the size of the margin below the X-coordinate axis. Ifpixelsis0, the size of the margin is selected automatically. The default is0. β¨-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. Ifbooleanis 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 is1. π¦-buffergraph booleanβ Indicates whether to draw the graph into a pixmap first. Ifbooleanis 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-bufferelementsoff. See the SPEED TIPS section. The default is1. π₯-cursor cursorβ Specifies the widget's cursor. The default cursor iscrosshair. π-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'sclosestoperation below). Data points further thanpixelsaway are ignored. The default is0.5i. πΈ-height pixelsβ Specifies the requested height of widget. The default is4i. β-invertxy booleanβ Indicates whether the placement X-axis and Y-axis should be inverted. Ifbooleanis true, the X and Y axes are swapped. The default is0. π-justify justifyβ Specifies how the title should be justified. This matters only when the title contains more than one line of text.Justifymust beleft,right, orcenter. The default iscenter. π-leftmargin pixelsβ Sets the size of the margin from the left edge of the window to the Y-coordinate axis. Ifpixelsis0, the size is calculated automatically. The default is0. β¨-plotbackground colorβ Specifies the background color of the plotting area. The default iswhite. π€-plotborderwidth pixelsβ Sets the width of the 3-D border around the plotting area. The-plotreliefoption determines if a border is drawn. The default is2. π-plotpadx padβ Sets the amount of padding to be added to the left and right sides of the plotting area.Padcan be a list of one or two screen distances. Ifpadhas two elements, the left side of the plotting area entry is padded by the first distance and the right side by the second. Ifpadis just one distance, both the left and right sides are padded evenly. The default is8. π¦-plotpady padβ Sets the amount of padding to be added to the top and bottom of the plotting area.Padcan be a list of one or two screen distances. Ifpadhas two elements, the top of the plotting area is padded by the first distance and the bottom by the second. Ifpadis just one distance, both the top and bottom are padded evenly. The default is8. π-plotrelief reliefβ Specifies the 3-D effect for the plotting area.Reliefindicates how the interior of the plotting area should appear relative to rest of the strip chart; for example,raisedmeans the plot should appear to protrude from the strip chart, relative to the surface of the strip chart. The default issunken. π-relief reliefβ Specifies the 3-D effect for the widget.Reliefindicates how the strip chart should appear relative to widget it is packed into; for example,raisedmeans the strip chart should appear to protrude. The default isflat. π-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. Ifpixelsis than1, the margin size is selected automatically. π-takefocus focusβ Provides information used when moving the focus from window to window via keyboard traversal (e.g.,TabandShift-Tab). Iffocusis0, this means that this window should be skipped entirely during keyboard traversal.1means 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. Ifimageisn't"", the background is tiled usingimage. Otherwise, the normal background color is drawn (see the-backgroundoption).Imagemust be an image created using the Tkimagecommand. The default is"". πΈ-title textβ Sets the title totext. Iftextis"", no title will be displayed. π-topmargin pixelsβ Specifies the size of the margin above the x2 axis. Ifpixelsis0, the margin size is calculated automatically. β¨-width pixelsβ Specifies the requested width of the widget. The default is5i. π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.Itemmust be eitherleftmargin,rightmargin,topmargin,bottommargin,plotwidth, orplotheight. π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 aselement. γ°οΈ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,fileNameis 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 imagephotoName.PhotoNameis 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?...β See the AXIS COMPONENTS section. β‘οΈpathName x2axis operation ?arg?...β See the AXIS COMPONENTS section. β¬ οΈpathName yaxis operation ?arg?...β See the AXIS COMPONENTS section. β¬οΈ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 modular main character energy. π
π§ 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 what controls which region of data gets plotted. Points that fall outside the minimum and maximum limits of the axis? Not plotted, periodt. By default, those min and max limits are figured out from the data itself, but you can reset either limit if you want.
You can create and use several axes at once β no cap. To make one, you invoke the axis component and its create operation.
# Create a new axis called "temperature"
.s axis create temperature
You map data elements to an axis using the element's -mapy and -mapx configuration options. Those 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
While you can have many axes, only four can be displayed at the same time. They get drawn in each of the margins surrounding the plotting area. The axes x and y are drawn in the bottom and left margins. The axes x2 and y2 are drawn in the top and right margins. Only x and y are shown by default. And note: the axes can have different scales, iykyk.
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 in the bottom, yaxis in the left, x2axis in the top, and y2axis in the right.
# Display the axis temperature in the left margin.
.s yaxis use temperature
You can configure axes in so many ways, it's giving custom. The axis scale can be linear or logarithmic. The values along the axis can monotonically increase or decrease. If you need custom tick labels, you can specify a Tcl procedure to format the label however you want. You can control how ticks are drawn by changing the major tick interval or the number of minor ticks. You can even define non-uniform tick intervals, like for time-series plots. Obsessed.
pathName axis cget axisName option
Returns the current value of the option given by option for axisName. Option can 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, you get a list describing all the current options for axisName. If option is specified but value isn't, 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, bestie:
-autorangerange β 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 is0.0, the range is determined from the limits of the data. If-minor-maxare specified, they override this option. The default is0.0. slay-colorcolor β Sets the color of the axis and tick labels. The default isblack.-commandprefix β 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"".
Please note that 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. do not bestie.
-descendingboolean β Indicates whether the values along the axis are monotonically increasing or decreasing. If boolean is true, the axis values will be decreasing. The default is0.-hideboolean β Indicates whether the axis is displayed.-justifyjustify β Specifies how the axis title should be justified. This matters only when the axis title contains more than one line of text. Justify must beleft,right, orcenter. The default iscenter.-limitsformatStr β 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"".-linewidthpixels β Sets the width of the axis and tick lines. The default is1pixel.-logscaleboolean β Indicates whether the scale of the axis is logarithmic or linear. If boolean is true, the axis is logarithmic. The default scale is linear.-looseboolean β 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 is0.-majorticksmajorList β 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"".-maxvalue β 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"".-minvalue β 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"".-minorticksminorList β 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 from0.0to1.0, designating the placement of a minor tick. No minor ticks are drawn if the-majortickoption is also set. If minorList is"", minor ticks will be automatically computed. The default is"".-rotatetheta β Specifies 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 is0.0degrees.-shiftbyvalue β 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 is0.0, then no automatic shifting is done. The default is0.0.-showticksboolean β Indicates whether axis ticks should be drawn. If boolean is true, ticks are drawn. If false, only the axis line is drawn. The default is1.-stepsizevalue β 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.-subdivisionsnumber β Indicates how many minor axis ticks are to be drawn. For example, if number is two, only one minor tick is drawn. If number is one, no minor ticks are displayed. The default is2.-tickfontfontName β Specifies the font for axis tick labels. The default is*-Courier-Bold-R-Normal-*-100-*.-ticklengthpixels β 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 is0.1i.-titletext β Sets the title of the axis. If text is"", no axis title will be displayed.-titlecolorcolor β Sets the color of the axis title. The default isblack.-titlefontfontName β Specifies the font for axis title. The default is*-Helvetica-Bold-R-Normal-*-14-140-*.
Axis configuration options can 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. 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 safe to delete axes mapped to elements. no stress
pathName axis invtransform axisName valueβ does the inverse glow-up β¨ it takes a screen coordinate value and turns it back into a graph coordinate by un-mapping it throughaxisName. Hands you back the graph coordinate. It's giving "undo" but make it math.pathName axis limits axisNameβ returns a list of the min and max limits foraxisName, bestie. The order is literallymin max, don't mix them up πpathName axis names ?pattern?...β returns a list of axes matching zero or more patterns. If you pass no pattern argument at all, you just get the names of all the axes. no cap πpathName axis transform axisName valueβ transforms the coordinate value into a screen coordinate by mapping it toaxisName, and returns the transformed screen coordinate. the reverse ofinvtransform, periodt.
okay so here's the tea β only four axes can be displayed at the same time. By default those four are x, y, x2, and y2. You can swap a different axis in using the use operation of the special axis components: xaxis, x2axis, yaxis, and y2axis. like so:
.g create axis temp
.g create axis time
...
.g xaxis use temp
.g yaxis use time
Only the axes you've specified for use actually get displayed on the screen. the others are just... lurking π
The xaxis, x2axis, yaxis, and y2axis components operate on an axis location rather than a specific axis β which is different from how the more general axis component rolls. The xaxis component manages the X-axis sitting in the bottom margin (whatever axis that happens to be). Same deal for yaxis with the Y-axis in the left margin, x2axis with the top X-axis, and y2axis with 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. Honestly these components can be way more convenient than constantly figuring out which axes are currently being displayed by the graph. main character energy tbh π
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β returns the current value of the configuration option given by option.pathName axis configure ?option value?...β queries or modifies the configuration options of the axis.pathName axis invtransform valueβ converts a screen coordinate value back to a graph coordinate.pathName axis limitsβ returns the minimum and maximum limits for the axis.pathName axis transform valueβ converts a graph coordinate value to a screen coordinate.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're 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. That means they can be quickly drawn and erased without redrawing the entire strip chart. efficiency queen π β¨
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 hairsconfigureoperation.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 isblack. π€-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 isyes. π-linewidth pixelsβ Set the width of the cross hair lines. The default is1.-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 be 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 of the cross hairs. (that's the original's typo, bestie, I'm not touching it π)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. it's giving glow-up for your data points fr fr πΈ
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 theelement configureoperation.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. Returns0, if no data point within the threshold distance can be found, otherwise1is 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 as2or1.2i. If this option isn't specified, then it defaults to the value of the stripchart's-halooption.-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 to0.
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 the option 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 isactiveLine.-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 isdefcolor, then the color will be the same as the-coloroption. The default isdefcolor.-hide booleanβ Indicates whether the element is displayed. The default isno.-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 is0, no connecting lines will be drawn between symbols. The default is0.-mapx xAxisβ Selects the X-axis to map the element's X-coordinates onto. XAxis must be the name of an axis. The default isx.-mapy yAxisβ Selects the Y-axis to map the element's Y-coordinates onto. YAxis must be the name of an axis. The default isy.-offdash colorβ Sets the color of the stripes when traces are dashed (see the-dashesoption). If color is"", then the "off" pixels will represent gaps instead of stripes. If color isdefcolor, then the color will be the same as the-coloroption. The default isdefcolor.-outline colorβ Sets the color or the outline around each symbol. If color is"", then no outline is drawn. If color isdefcolor, then the color will be the same as the-coloroption. The default isdefcolor.
-outlinewidthpixels β sets how chunky the outline around each symbol is. If pixels is0, bestie, no outline gets drawn at all, like it said "not today." The default is1.-pixelspixels β sets the size of the symbols. If pixels is0, no symbols get drawn, periodt. The default is0.125i.-scalesymbolsboolean β okay so if boolean is true, the size of the symbols drawn for elemName will actually change with the scale of the X-axis and Y-axis. Here's the tea: at the exact moment this option gets set, the current ranges of the axes are saved as the normalized scales (that's scale factor1.0, iykyk) and the element is drawn at its designated size (peep the-pixelsoption). As the scale of the axes change, the symbol gets scaled according to the smaller of the X-axis and Y-axis scales. If boolean is false, the element's symbols are drawn at the designated size no matter what the axis scales are doing. The default is0.-smoothsmooth β specifies how connecting line segments are drawn between data points. smooth can be eitherlinear,step,natural, orquadratic. If smooth islinear, a single line segment is drawn, connecting both data points. When smooth isstep, two line segments are drawn β the first is a horizontal line segment which steps the next x-coordinate, and the second is a vertical line, moving to the next y-coordinate. Bothnaturalandquadraticgenerate multiple segments between data points. Ifnatural, the segments are generated using a cubic spline. Ifquadratic, a quadratic spline is used. The default islinear.-stylesstyleList β specifies what pen to use based upon the range of weights given. styleList is a list of style specifications. Each style specification, in turn, is a list consisting of a pen name, and optionally a minimum and maximum range. Data points whose weight (see the-weightoption) falls in this range are drawn with this pen. If no range is specified it defaults to the number of the pen in the list.-symbolsymbol β specifies the symbol for data points. symbol can be eithersquare,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 iscircle.-weightswVec β specifies the weights of the individual data points. This, in conjunction with the list pen styles (see the-stylesoption) controls how data points are drawn. wVec is the name of a BLT vector or a list of numeric expressions representing the weights for each data point.-xdataxVec β specifies the x-coordinates of the data. xVec is the name of a BLT vector or a list of numeric expressions.-ydatayVec β specifies the y-coordinates of the data. yVec is the name of a BLT vector or a list of numeric expressions.
Element configuration options may also be set by the option command. The resource class is Element. The resource name is the name of the element.
option add *Stripchart.Element.symbol line
option add *Stripchart.e1.symbol line
pathName element createelemName ?option value?... β creates a new element elemName. It's an error if an element elemName already exists. If additional arguments are present, they specify options valid forelement configureoperation.pathName element deactivateelemName ?elemName?... β deactivates all the elements matching pattern. Elements whose names match any of the patterns given are redrawn using their normal colors.pathName element delete?elemName?... β deletes all the named elements. The graph is automatically redrawn.pathName element existselemName β returns1if an element elemName currently exists and0otherwise.pathName element names?pattern?... β returns the elements matching one or more pattern. If no pattern is given, the names of all elements is returned.pathName element show?nameList? β queries or modifies the element display list. The element display list designates the elements drawn and in what order. NameList is a list of elements to be displayed in the order they are named. If there is no nameList argument, the current display list is returned.pathName element typeelemName β returns the type of elemName. If the element is a bar element, the commands returns the string"bar", otherwise it returns"line".
π GRID COMPONENT π
Grid lines extend from the major and minor ticks of each axis horizontally or vertically across the plotting area. The following operations are available for grid lines, bestie. π«Ά
pathName grid cgetoption β returns the current value of the grid line configuration option given by option. Option may be any option described below for thegrid configureoperation.pathName grid configure?option value?... β queries or modifies the configuration options for grid lines. If option isn't specified, a list describing all the current grid 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 grid line option option is set to value. The following options are valid for grid lines:-colorcolor β sets the color of the grid lines. The default isblack.-dashesdashList β 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. Each number must be between1and255. If dashList is"", the grid will be solid lines.-hideboolean β indicates whether the grid should be drawn. If boolean is true, grid lines are not shown. The default isyes.-linewidthpixels β sets the width of grid lines. The default width is1.-mapxxAxis β specifies the X-axis to display grid lines. XAxis must be the name of an axis. The default isx.-mapyyAxis β specifies the Y-axis to display grid lines. YAxis must be the name of an axis. The default isy.-minorboolean β indicates whether the grid lines should be drawn for minor ticks. If boolean is true, the lines will appear at minor tick intervals. The default is1.
Grid configuration options may also be set by 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 the grid lines.pathName grid onβ turns on the display the grid lines.pathName grid toggleβ toggles the display of the grid.
π LEGEND COMPONENT π
The legend displays a list of the data elements. Each entry consists of the element's symbol and label. The legend can appear in any margin (the default location is in the right margin). It can also be positioned anywhere within the plotting area. It's giving very flexible, ngl. β¨
The following operations are valid for the legend.
pathName legend activatepattern... β selects legend entries to be drawn using the active legend colors and relief. All entries whose element names match pattern are selected. To be selected, the element name must match only one pattern.pathName legend cgetoption β returns the current value of a legend configuration option. Option may be any option described below in thelegend configureoperation.pathName legend configure?option value?... β queries or modifies the configuration options for the legend. If option isn't specified, a list describing the current legend 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 legend option option is set to value. The following options are valid for the legend:-activebackgroundcolor β sets the background color for active legend entries. All legend entries marked active (see thelegend activateoperation) are drawn using this background color.-activeborderwidthpixels β sets the width of the 3-D border around the outside edge of the active legend entries. The default is2.-activeforegroundcolor β sets the foreground color for active legend entries. All legend entries marked as active (see thelegend activateoperation) are drawn using this foreground color.-activereliefrelief β specifies the 3-D effect desired for active legend entries. Relief denotes how the interior of the entry should appear relative to the legend; for example,raisedmeans the entry should appear to protrude from the legend, relative to the surface of the legend. The default isflat.-anchoranchor β tells how to position the legend relative to the positioning point for the legend. This is dependent on the value of the-positionoption. The default iscenter.leftorrightβ the anchor describes how to position the legend vertically.toporbottomβ the anchor describes how to position the legend horizontally.
@x,yβ the anchor tells you how to place the legend relative to that positioning point, bestie. Like if anchor iscenter, the legend is literally centered right on the point. If anchor isn, the legend gets drawn so its top-center point sits at the positioning point. It's giving "pin the top of my rectangle here." πplotareaβ now the anchor is about where in the plotting area things go. If anchor iscenter, the legend is centered in the plotting area. If anchor isne, the legend gets drawn so it occupies the upper right corner of the plotting area. Slay positioning, no cap. β¨
-backgroundcolor β sets the background color of the legend. If color is"", the legend background is transparent (lowkey invisible backdrop, very ethereal π¦).-borderwidthpixels β sets the width of that 3-D border around the outside edge of the legend, but only if such a border is being drawn (thereliefoption is the one deciding that, iykyk). The default is2pixels.-fontfontName β fontName is the font used when drawing the labels of each element into the legend. The default is*-Helvetica-Bold-R-Normal-*-12-120-*.-foregroundcolor β sets the foreground color of the text drawn for the element's label. The default isblack.-hideboolean β says whether the legend should be displayed. If boolean is true, the legend will not be drawn. The default isno.-ipadxpad β 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 gets padded by the first distance and the right side by the second. If pad is just one distance, both the left and right sides get padded evenly. The default is2.-ipadypad β sets an amount of internal padding added to 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 gets padded by the first distance and the bottom by the second. If pad is just one distance, both the top and bottom get padded evenly. The default is2.-padxpad β sets the padding on the left and right exteriors of the legend. pad can be a list of one or two screen distances. If pad has two elements, the left side of the legend gets padded by the first distance and the right side by the second. If pad has just one distance, both the left and right sides get padded evenly. The default is4.-padypad β sets the padding above and below the legend. pad can be a list of one or two screen distances. If pad has two elements, the area above the legend gets padded by the first distance and the area below by the second. If pad is just one distance, both the top and bottom areas get padded evenly. The default is0.-positionpos β specifies where the legend is drawn. The-anchoroption also affects where the legend ends up, so they're besties fr fr. If pos isleft,left,top, orbottom, the legend is drawn in the specified margin. If pos isplotarea, 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 exact coordinates. The default isright.-raisedboolean β indicates whether the legend sits above or below the data elements. This only matters if the legend is in the plotting area. If boolean is true, the legend gets drawn on top of any elements that might overlap it. The default isno.-reliefrelief β 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,raisedmeans the legend should look like it's protruding from the strip chart, relative to the surface of the strip chart. The default issunken.
Legend configuration options may also be set by the option command. The resource name and class are legend and Legend respectively. π
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. All entries whose element names match pattern are selected. To be selected, the element name must match only one pattern. Periodt.
πΈ 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. Sad but true. π
β¨ PEN COMPONENTS β¨
Pens define attributes β both symbol and line style β for elements. Pens 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. 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 β peep the element's -weight and -style options for that. π
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 energy, honestly.
.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
An element can use several pens at once. This is done 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. The way that just *works*β¦ iconic.
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. π«Ά
-colorcolor β sets the color of the traces connecting the data points.-dashesdashList β sets the dash style of the element line. dashList is a list of up to11numbers that alternately represent the lengths of the dashes and gaps on the element line. Each number must be between1and255. If dashList is"", the lines will be solid.-fillcolor β sets the interior color of symbols. If color is"", then the interior of the symbol is transparent. If color isdefcolor, then the color will be the same as the-coloroption. The default isdefcolor.-linewidthpixels β sets the width of the connecting lines between data points. If pixels is0, no connecting lines will be drawn between symbols. The default is0.-offdashcolor β sets the color of the stripes when traces are dashed (see the-dashesoption). If color is"", then the "off" pixels will represent gaps instead of stripes. If color isdefcolor, then the color will be the same as the-coloroption. The default isdefcolor.-outlinecolor β sets the color of the outline around each symbol. If color is"", then no outline is drawn. If color isdefcolor, then the color will be the same as the-coloroption. The default isdefcolor.-outlinewidthpixels β sets the width of the outline bordering each symbol. If pixels is0, no outline will be drawn. The default is1.-pixelspixels β sets the size of symbols. If pixels is0, no symbols will be drawn. The default is0.125i.-symbolsymbol β specifies the symbol for data points. symbol can be eithersquare,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 iscircle.-typeelemType β specifies the type of element the pen is to be used with. This option should only be employed when creating the pen. This is for those that wish to mix different types of elements (barsandlines) on the same graph. The default type is"line".
Pen config can also be set thru the option command, bestie. The resource class is Pen. The resource names are the names of the pens. Obsessed with that for you.
option add *Stripchart.Pen.Color blue
option add *Stripchart.activeLine.color green
pathName pen create penName ?option value?...β makes a brand new pen named penName. π No pen with that same name can already exist (no duplicates, periodt). The option and value pairs are the same ones described up above in thepen configureoperation.pathName pen delete ?penName?...β yeets the named pens. ποΈ But lowkey, a pen isn't really deleted until it's no longer in use, so it's totally safe to delete pens that are mapped to elements. No cap.pathName pen names ?pattern?...β hands you back a list of pens that match zero or more patterns. If you don't pass any pattern argument, you just get the names of all the pens. Every single one. β¨
π POSTSCRIPT COMPONENT π
The strip chart can generate encapsulated PostScript output, and honestly? it's giving printer icon energy. π¨οΈβ¨ There are several configuration options you can set to control how the plot gets generated. You can change the page dimensions and borders. The plot itself can be scaled, centered, or rotated to landscape. And the PostScript output can be written directly to a file or handed back through the interpreter.
Here are the postscript operations you've got, bestie:
pathName postscript cget optionβ returns the current value of the postscript option you asked for. option can be any option described below for thepostscript configureoperation.pathName postscript configure ?option value?...β queries or modifies the config options for PostScript generation. π¦ If option isn't specified, you get a list describing the current postscript options forpathName. If option is specified but no value, you get a list describing that option. And if you pass one or more option and value pairs, then for each pair, the postscript option option gets set to value. Here's every postscript option on the menu:-centerboolean β says whether the plot should be centered on the PostScript page. If boolean is false, the plot gets parked in the upper left corner of the page instead. Default is1. π-colormapvarName β varName has to be the name of a global array variable that specifies a color mapping from the X color name to PostScript. Every element of varName must be PostScript code that sets a particular color value (e.g.1.0 1.0 0.0 setrgbcolor). When it's outputting color info in PostScript, the array variable varName gets checked to see if an element named after the color exists. If it does, it uses that element's value as the PostScript command to set the color. If this option hasn't been specified, or if there's no entry in varName for a given color, then it just uses the red, green, and blue intensities from the X color. π-colormodemode β specifies how to output color info. mode must be eithercolor(for full color output),gray(converts all colors to their gray-scale equivalents), ormono(converts foreground colors to black and background colors to white). Default mode iscolor. π¨-fontmapvarName β varName has to be the name of a global array variable that specifies a font mapping from the X font name to PostScript. Every element of varName must be a Tcl list with one or two elements, which are the name and point size of a PostScript font. When it's outputting PostScript commands for a particular font, the array variable varName gets checked to see if an element for the specified font exists. If there is such an element, then the font info 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 gets examined in an attempt to guess what PostScript font to use. This works only for fonts whose foundry property is Adobe (like Times, Helvetica, Courier, etc.). And if all of that fails, then the font defaults toHelvetica-Bold. π-decorationsboolean β says whether 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 get generated. Default is1. β¨-heightpixels β 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 is0, the height is the same as the displayed height. Default is0.-landscapeboolean β 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 to0.-maxpectboolean β tells it to scale the plot so that it fills the PostScript page. The aspect ratio of the strip chart is still retained tho. Default is0. π₯-padxpad β 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 gets padded by the first distance and the right border by the second. If pad has just one distance, both the left and right borders get padded evenly. Default is1i.-padypad β 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 gets padded by the first distance and the bottom border by the second. If pad has just one distance, both the top and bottom borders get padded evenly. Default is1i.-paperheightpixels β sets the height of the postscript page. This can be used to select between different page sizes (letter, A4, etc). Default height is11.0i. π-paperwidthpixels β sets the width of the postscript page. This can be used to select between different page sizes (letter, A4, etc). Default width is8.5i. π-widthpixels β 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 is0, the width is the same as the widget's width. Default is0.
Postscript config options can also be set by the option command, btw. The resource name and class are postscript and Postscript respectively.
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 instead. If any option-value pairs are present, they set config options controlling how the PostScript gets generated. option and value can be anything accepted by thepostscript configureoperation above.
π MARKER COMPONENTS π
Markers are simple drawing procedures used to annotate or highlight areas of the strip chart. ποΈ They come in 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 in behind them. You can change that 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. π
Here are the operations 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 config option given by option. option may be any option described below in theconfigureoperation.pathName marker configure markerId ?option value?...β queries or modifies the config options for markers. If option isn't specified, a list describing the current options for markerId is returned. If option is specified but no 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 gets set to value. π«Ά
The following options are valid for all markers. Each type of marker also has its own type-specific options β those get described in the sections below.
-coords coordListβ tells the marker where to live on the chart.coordListis a list of graph coordinates, and how many you need depends on the marker type, bestie. Text, image and window markers only want two coords (a lil X-Y situation). Bitmap markers take either two or four (four = the corners of the bitmap, so it knows how to stretch). Line markers need at least four coords, and polygons need at least six. IfcoordListis"", the marker simply does not get displayed. Default is"". π-element elemNameβ links the marker to the elementelemName. It's giving ride or die: the marker only draws if that element is currently displayed too (peep the element's show operation). IfelemNameis"", the marker is always drawn. Default is"".-hide booleanβ is the marker drawn or not? Ifbooleanis true, it is not drawn. Default isno.-mapx xAxisβ which X-axis the marker's X-coordinates get mapped onto.xAxishas to be the name of an axis. Default isx. β¨-mapy yAxisβ which Y-axis the marker's Y-coordinates get mapped onto.yAxishas to be the name of an axis. Default isy. β¨-name markerIdβ changes the identifier for the marker. ThatmarkerIdcan NOT already be in use by another marker (no stealing names, it's not cute). If you don't set this option, the marker's name gets uniquely generated for you. π-under booleanβ whether the marker is drawn below or above the data elements. Ifbooleanis true, the marker gets drawn underneath the data element symbols and lines. Otherwise it's on top of the element, main character style. Default is0.-xoffset pixelsβ a screen distance to offset the marker horizontally.pixelsis a valid screen distance, like2or1.2i. Default is0.-yoffset pixelsβ a screen distance to offset the marker vertically.pixelsis a valid screen distance, like2or1.2i. Default is0.
Marker configuration options can also be set with the option command, no cap. The resource class is either BitmapMarker, ImageMarker, LineMarker, PolygonMarker, TextMarker, or WindowMarker, depending on the marker type. The resource name is the name of the marker. So like:
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. And type may be either text, line, bitmap, image, polygon, or window β pick your fighter. This command returns the marker identifier, which you then use as the markerId argument in all the other marker-related commands. If the -name option is used, it overrides the normal marker identifier. And if the name you provided is already used for another marker, the new marker straight up replaces the old one. π
π pathName marker delete ?name?...
Removes one or more markers. The graph automatically gets redrawn without the marker, so like, it cleans up after itself. π§Ή
π pathName marker exists markerId
Returns 1 if the marker markerId exists and 0 otherwise. Simple as that, bestie.
π 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 get returned. Filtered, curated, iconic. π₯
π 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 how many coordinates you specify. If there are two coordinates, they specify the position of the top-left corner of the bitmap, and the bitmap keeps its normal width and height. If there are four coordinates, the first and second pairs of coordinates represent the corners of the bitmap β and the bitmap gets stretched or reduced as necessary to fit into that bounding rectangle. Glow-up or shrink-down, either way. π¦
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 one setting a configuration option for the marker. Those 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. Ifcoloris"", the background color will be transparent. The default background color iswhite.-bitmap bitmapβ specifies the bitmap to be displayed. Ifbitmapis"", the marker will not be displayed. The default is"".-foreground colorβ sets the foreground color of the bitmap. The default foreground color isblack.-mask maskβ specifies a mask for the bitmap to be displayed. This mask is a bitmap itself, denoting the pixels that are transparent. Ifmaskis"", all pixels of the bitmap will be drawn. The default is"". β¨-rotate thetaβ sets the rotation of the bitmap.thetais 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 is0.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 one setting a configuration option for the marker. Those same option-value pairs may be used with the marker's configure operation.
The following options are specific to image markers:
-anchor anchorβanchortells how to position the image relative to the positioning point for the image. For example, ifanchoriscenterthen the image is centered on the point; ifanchorisnthen 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 tocenter. π-image imageβ specifies the image to be drawn. Ifimageis"", 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 the marker's create operation in the form:
pathName marker create line ?option value?...
There may be many option-value pairs, each one setting a configuration option for the marker. Those 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. Heads up, this option only affects the line color when the-stippleoption is set. If this option isn't specified then it defaults towhite.-dashes dashListβ sets the dash style of the line.dashListis a list of up to11numbers that alternately represent the lengths of the dashes and gaps on the line. Each number must be between1and255. IfdashListis"", the marker line will be solid. π-foreground colorβ sets the foreground color. The default foreground color isblack.-linewidth pixelsβ sets the width of the lines. The default width is0.-stipple bitmapβ specifies a stipple pattern used to draw the line, rather than a solid line.bitmapspecifies a bitmap to use as the stipple pattern. Ifbitmapis"", 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's assumed the first and last points are connected (they're holding hands, obviously). 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 one setting a configuration option for the marker. Those 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.dashListis a list of up to11numbers that alternately represent the lengths of the dashes and gaps on the outline. Each number must be between1and255. IfdashListis"", the outline will be a solid line.-fill colorβ sets the fill color of the polygon. Ifcoloris"", then the interior of the polygon is transparent. The default iswhite.-linewidth pixelsβ sets the width of the outline of the polygon. Ifpixelsis zero, no outline is drawn. The default is0.-outline colorβ sets the color of the outline of the polygon. If the polygon is stippled (see the-stippleoption), then this represents the foreground color of the stipple. The default isblack.-stipple bitmapβ specifies that the polygon should be drawn with a stippled pattern rather than a solid color.bitmapspecifies a bitmap to use as the stipple pattern. Ifbitmapis"", then the polygon is filled with a solid color (if the-filloption 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 β lil notes to your future self, love that for you. 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 one setting a configuration option for the text marker. Those same option-value pairs may be used with the marker's configure operation.
The following options are specific to text markers:
-anchor anchorβanchortells how to position the text relative to the positioning point for the text. For example, ifanchoriscenterthen the text is centered on the point; ifanchorisnthen 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 iscenter. π-background colorβ sets the background color of the text string, bestie. ifcoloris"", the background goes transparent β¨. default iswhite.-font fontNameβ the font of the text, duh π . default is*-Helvetica-Bold-R-Normal-*-120-*.-foreground colorβ the foreground color of the text. default isblack. classic π€-justify justifyβ how the text gets justified. heads up: this only matters when the marker has more than one line of text, so don't stress otherwise.justifyhas to beleft,right, orcenter. default iscenterπ―.-padx padβ sets the padding on the left and right exteriors of the text.padcan be a list of one or two screen distances. two elements? left side gets padded by the first distance, right side by the second π«Ά. just one distance? both sides get padded evenly, no favorites. default is4.-padx... wait no,-pady padβ sets the padding above and below the text. same deal:padcan be one or two screen distances. two elements means the area above is padded by the first and the area below by the second; one distance means top and bottom get padded evenly. default is4. symmetry slay β¨-rotate thetaβ how many degrees to rotate the text, because why be straight when you could be angled π.thetais a real number for the angle of rotation. the marker gets rotated along its center first, and then it's drawn according to its anchor position. default is0.0.-text textβ the text of the marker, obviously π. the exact way that text shows up may be affected by other options, like-anchoror-rotate, so keep that in mind iykyk.
πͺ WINDOW MARKERS πͺ
A window marker displays a widget at a given position. it's giving "put a whole widget on my chart" and honestly? iconic.
Window markers get created with the marker's create operation, like this:
pathName marker create window ?option value?...
There may be many option-value pairs, and each one sets a configuration option for the marker. those same option-value pairs work with the marker's configure command too π
.
The following options are specific to window markers:
-anchor anchorβ tells how to position the widget relative to the widget's positioning point. for example, ifanchoriscenter, the widget is centered on the point π―; ifanchorisn, the widget gets displayed so that the top center point of the rectangular region occupied by the widget sits at the positioning point. this option defaults tocenter.-height pixelsβ the height to assign to the marker's window. if this option isn't specified, or if it's specified as"", then the window gets whatever height the widget requests internally π«Ά (let the widget be its own main character).-width pixelsβ the width to assign to the marker's window. if this option isn't specified, or if it's specified as"", then the window gets whatever width the widget requests internally.-window pathNameβ the widget to be managed.pathNamemust be a child of the stripchart widget, no exceptions bestie π¨.
π― GRAPH COMPONENT BINDINGS π―
Specific stripchart components β 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. so yes, they can be interactive β¨.
Not all event sequences are valid though. the only binding events that may be specified are the ones related to the mouse and keyboard β things like Enter, Leave, ButtonPress, Motion, and KeyPress π».
Only one element or marker can be picked during an event. meaning: if the mouse is directly over both an element and a marker, only the uppermost component gets selected π. this isn't true for legend entries β both a legend entry and an element (or marker) binding command will be invoked if both items are picked. legend stays winning, no cap.
It's possible for multiple bindings to match a particular event. this could happen, for example, if one binding is associated with the element name and another is associated with one of the element's tags (peep the -bindtags option). when this happens, all of the matching bindings get 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 like for the bind command. fr fr.
The -bindtags option for these components controls additional tag names which can be matched. implicitly, elements and markers always have tags matching their names β and setting the value of the -bindtags option doesn't change that π
.
π» C LANGUAGE API π»
Okay so you can manipulate data elements straight from the C language π€. there may be situations where translating the data values from ASCII strings is just too expensive. or maybe you wanna read data in a special file format. valid.
Data can be manipulated from the C language using BLT vectors. you specify the x and y data coordinates of an element as vectors and then manipulate the vector from C. the strip chart will be redrawn automatically after the vectors are updated β¨ (it's giving magic, it's giving no extra work for you).
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 gets 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, bestie:
- Try to minimize the number of data points. the more data points you're looking at, the more work the strip chart has to 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
-symboloption tonone. if you need to draw symbols, try using the simple symbols such assplusandscross. - Don't stipple or dash the element. solid lines are much faster β‘.
- If you update data elements frequently, try turning off the widget's
-bufferelementsoption. 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're 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, then the buffering becomes redundant. rip to the cache π
π§ LIMITATIONS π§
Auto-scale routines do not use requested min/max limits as boundaries when the axis is logarithmically scaled. just so you know π.
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. don't get attached, bestie π
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
And that's a wrap on the whole page, babe πΈ this was from BLT 2.5, dated 2.5, under the name blt::stripchart(3tcl) β go forth and chart your little heart out πβ¨π
π¦ where this page comes from
- debian bookworm: blt-dev 2.5.3+dfsg-4.1
- debian trixie: blt-dev 2.5.3+dfsg-8
- ubuntu jammy: blt-dev 2.5.3+dfsg-4.1build2
- ubuntu noble: blt-dev 2.5.3+dfsg-7build1
- ubuntu questing: blt-dev 2.5.3+dfsg-8
- ubuntu resolute: blt-dev 2.5.3+dfsg-8build1
- ubuntu stonking: blt-dev 2.5.3+dfsg-9
- Copyright 1991-1997 by Bell Labs Innovations for Lucent Technologies
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms