Graph marker MARKER command¶
Commands in this namespace document graph markers.
MARKER is used below as a placeholder for:
GRAPHINST marker
Markers are graph annotations. They are independent of graph elements and do not contribute to the calculation of axis limits.
With -renderer cairo, line markers, arrowheads, and polygon fills/outlines use -antialias.
Solid and stippled fills, colored dash gaps, caps, clipping, and -under ordering are supported.
Mapped outline segments remain independent, as in native drawing. XOR markers remain native.
Photo image markers use Cairo alpha compositing with existing placement and scaling. They clip to
the plot; -antialias does not resample their pixels. Source image changes refresh the marker.
Bitmap markers use Cairo with existing scaling, rotation, and masks. Their mapped pixels stay sharp;
-antialias affects rotated background polygons. An empty foreground uses Cairo with the native GC color.
Text-marker backgrounds use Cairo, including rotated edges, and clip to the plot. Text itself stays native.
Window and non-photo image markers keep their Tk rendering; line markers with an
empty -outline use Cairo with the native GC color.
Rbc provides six marker types:
Type |
Description |
|---|---|
|
Displays a Tk bitmap |
|
Displays a Tk image |
|
Displays one or more connected line segments |
|
Displays a filled and/or outlined polygon |
|
Displays text |
|
Displays an embedded Tk window |
A marker is created by specifying its type:
graph .g
.g marker create text -name label -coords {1.0 2.0} -text "Operating point"
.g marker create line -name limit -coords {0 5 10 5} -outline red
Unlike elements and pens, the marker name is not a positional argument of MARKER create. Use -name to
select an explicit name. If -name is omitted, Rbc generates a marker name.
Marker coordinates¶
Marker coordinates are graph coordinates and are mapped through the axes selected by -mapx and -mapy.
The number of coordinates depends on the marker type:
Marker type |
Coordinates |
|---|---|
|
One or two X-Y pairs |
|
One or two X-Y pairs |
|
Two or more X-Y pairs |
|
Three or more X-Y pairs |
|
One X-Y pair |
|
One X-Y pair |
For bitmap and image markers, one X-Y pair specifies the marker position. Two pairs specify opposite corners of a bounding rectangle. Bitmap markers are scaled to that rectangle. Photo images are likewise scaled to the rectangle; other Tk image types are drawn at their natural size.
Coordinate values may be Tcl numeric expressions. Inf, +Inf, and -Inf select elastic axis bounds.
An empty -coords value leaves the marker without drawable coordinates.
For example:
.g marker create text -coords {-Inf Inf} -anchor nw -text "upper left"
Drawing order¶
Markers have their own display order. MARKER before and MARKER after change the position of a marker in
that order.
By default markers are drawn over graph elements. The -under option changes whether an individual marker is
drawn below or above the element layer.
.g marker configure region -under yes
The marker ordering operations affect ordering between markers; they do not replace the -under setting.
Element association¶
-element associates a marker with an element:
.g marker create text -name note -element signal -coords {2 5} -text signal
The marker is displayed only while the associated element is displayed. An empty -element value removes the
association.
Marker bindings¶
Markers participate in graph component bindings. Bindings are made with MARKER bind.
Every marker has its marker name as an implicit binding tag. Additional tags are selected with -bindtags.
The default binding tags depend on the marker type:
Type |
Default |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
For example:
.g marker create text -name note -coords {1 2} -text "click me" -bindtags {annotation all}
.g marker bind annotation <Button-1> {
puts "annotation selected"
}
Marker types and options¶
All marker types share the coordinate, visibility, axis-mapping, naming, binding, state, drawing-order, and offset options described below. Each concrete marker type then adds its own drawing options.
MARKER cget and MARKER configure operate on the option table of the concrete marker being addressed. An
option valid for one marker type is not necessarily valid for another.
Common marker options¶
Option |
Database name |
Database class |
Description |
|---|---|---|---|
|
|
|
Specifies additional binding tags associated with the marker. The marker name is always an implicit binding tag. The default class tag depends on the marker type. |
|
|
|
Specifies the graph coordinates of the marker. The required number of coordinates depends on the marker type. The default is empty. Each coordinate accepts a Tcl numeric expression; Inf, +Inf and -Inf select elastic bounds. |
|
|
|
Associates the marker with an element. The marker is displayed only while that element is displayed. An empty value removes the association. |
|
|
|
Specifies whether the marker is hidden. The default is |
|
|
|
Specifies the X axis used to map marker coordinates. The axis must exist and must be an X axis. The default is |
|
|
|
Specifies the Y axis used to map marker coordinates. The axis must exist and must be a Y axis. The default is |
|
— |
— |
Specifies the marker name. During creation, an omitted name is generated automatically. Reconfiguring |
|
|
|
Specifies the marker state: |
|
|
|
Specifies whether the marker is drawn below graph elements rather than above them. The default is |
|
|
|
Adds a horizontal screen-coordinate offset after the marker has been mapped. The default is |
|
|
|
Adds a vertical screen-coordinate offset after the marker has been mapped. The default is |
Bitmap marker options¶
Bitmap markers display a Tk bitmap.
.g marker create bitmap -name bitmap1 -coords {1 2} -bitmap questhead
In addition to the common marker options, bitmap markers support:
Option |
Database name |
Database class |
Description |
|---|---|---|---|
|
|
|
Specifies how the bitmap is positioned relative to its reference coordinates. The default is |
|
— |
— |
Specifies the bitmap background color. This is a synonym for |
|
— |
— |
Synonym for |
|
|
|
Specifies the Tk bitmap to display. |
|
|
|
Specifies the bitmap background color. |
|
— |
— |
Specifies the bitmap foreground color. This is a synonym for |
|
— |
— |
Synonym for |
|
|
|
Specifies an optional bitmap mask. |
|
|
|
Specifies the bitmap foreground color. |
|
|
|
Specifies the rotation angle in degrees. The default is |
Image marker options¶
Image markers display a Tk image.
image create photo icon -file icon.png
.g marker create image -name iconMarker -coords {1 2} -image icon
In addition to the common marker options, image markers support:
Option |
Database name |
Database class |
Description |
|---|---|---|---|
|
|
|
Specifies how the image is positioned relative to its coordinate. The default is |
|
|
|
Specifies the Tk image to display. |
Line marker options¶
Line markers draw connected line segments through their X-Y coordinate pairs.
.g marker create line -name threshold -coords {-Inf 5 Inf 5} -outline red -linewidth 2
In addition to the common marker options, line markers support:
Option |
Database name |
Database class |
Description |
|---|---|---|---|
|
|
|
Specifies whether arrowheads are drawn at the ends of the line marker. |
|
|
|
Specifies the arrowhead geometry as three screen distances. |
|
|
|
Specifies the line cap style. Accepted styles are |
|
|
|
Specifies the dash pattern. An empty value selects a solid line. Each numeric list item accepts a Tcl integer expression. |
|
|
|
Specifies the offset into the dash pattern. The default is |
|
|
|
Specifies the color used for the off portions of a dashed line. An empty value uses ordinary on/off dashes. The default is empty. |
|
|
|
Specifies how adjacent segments are joined. Accepted styles are |
|
|
|
Specifies the line width. The default is |
|
|
|
Specifies the primary line color. The default is |
|
|
|
Specifies whether the line is drawn using XOR drawing. The default is |
Arrowheads¶
Line markers may draw an arrowhead at either end of the line by using the -arrow option. Accepted values
are none, first, last, and both.
For example:
graph .g
pack .g
.g marker create line -name direction -coords {0 0 5 4 10 2} -outline red -linewidth 2 -arrow last
The arrowhead shape may be adjusted with -arrowshape. It accepts three screen distances {a b c}:
.g marker configure direction -arrow both -arrowshape {8 10 3}
a specifies the distance from the arrowhead neck to its tip, b specifies the distance from the trailing
points to the tip, and c specifies the distance from the outside edge of the line to the trailing points.
The arrowhead uses the line marker’s -outline color. The line shaft is shortened to the neck of the
arrowhead so that it does not protrude through the filled arrowhead.
Screen-distance units accepted by Tk may also be used:
.g marker configure direction -arrowshape {8p 10p 3p}
Polygon marker options¶
Polygon markers draw the closed polygon formed by their coordinate pairs.
.g marker create polygon -name region -coords {0 0 4 0 4 3 0 3} -fill lightblue -outline navy
In addition to the common marker options, polygon markers support:
Option |
Database name |
Database class |
Description |
|---|---|---|---|
|
|
|
Specifies the outline cap style. Accepted styles are |
|
|
|
Specifies the dash pattern used for the polygon outline. An empty value selects a solid outline. Each numeric list item accepts a Tcl integer expression. |
|
|
|
Specifies the polygon fill colors. The value may contain one foreground color or a foreground and background color. With |
|
|
|
Specifies how adjacent outline segments are joined. Accepted styles are |
|
|
|
Specifies the width of the polygon outline. The value must be non-negative. The default is |
|
|
|
Specifies the polygon outline colors. The value may contain one foreground color or a foreground and background color. For dashed outlines, the second color is used for the off portions of the dash pattern. An empty value disables the outline color. The default foreground color is |
|
|
|
Specifies an optional stipple bitmap used when filling the polygon. An empty value selects an unstippled fill. |
|
|
|
Specifies whether the polygon outline uses XOR drawing. The default is |
Text marker options¶
Text markers display one or more lines of text.
.g marker create text -name annotation -coords {3 8} -text "maximum" -anchor s
In addition to the common marker options, text markers support:
Option |
Database name |
Database class |
Description |
|---|---|---|---|
|
|
|
Specifies how the text is positioned relative to its coordinate. The default is |
|
|
|
Specifies the text background color. This is a synonym for |
|
— |
— |
Synonym for |
|
— |
— |
Specifies the text background color. |
|
|
|
Specifies the font used to draw the text. |
|
|
|
Specifies the text color. This is a synonym for |
|
— |
— |
Synonym for |
|
|
|
Specifies justification of multiline text. The default is |
|
— |
— |
Specifies the text color. The default is |
|
|
|
Specifies horizontal padding around the text. The default is |
|
|
|
Specifies vertical padding around the text. The default is |
|
|
|
Specifies the text rotation angle in degrees. The default is |
|
|
|
Specifies the text shadow. |
|
|
|
Specifies the text to display. |
Window marker options¶
Window markers display a Tk window inside the graph.
The window must be managed by the graph marker.
button .g.info -text Info
.g marker create window -name infoMarker -coords {2 4} -window .g.info
In addition to the common marker options, window markers support:
Option |
Database name |
Database class |
Description |
|---|---|---|---|
|
|
|
Specifies how the window is positioned relative to its coordinate. The default is |
|
|
|
Specifies an explicit positive height for the embedded window. When left at its initial default of |
|
|
|
Specifies an explicit positive width for the embedded window. When left at its initial default of |
|
|
|
Specifies the Tk window managed by the marker. The window must be a direct child of the graph widget. An empty value removes the managed window. |
Option database¶
Marker options may be supplied through Tk’s option database. Each concrete marker type has its own resource class:
Marker type |
Resource class |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
The resource name is the marker name.
For example:
option add *Graph.TextMarker.Foreground navy
option add *Graph.LineMarker.LineWidth 2
Copyright (c) George Yashin