Plotchart(n)

๐Ÿ“ฆ
version 0.7 ยท 3 versions
, in alpine 3.24

๐Ÿฆ‹ Plotchart(n) ๐Ÿฆ‹

hii bestie, this is the manual page for Plotchart, section n of the man pages, and it's genuinely one of the cuter things you'll read today. settle in ๐Ÿ’–


โœจ NAME โœจ

Plotchart โ€” a simple plotting and charting package. that's it, that's the whole name section, but lowkey it's the whole personality too ๐ŸŽ€


๐ŸŒˆ SYNOPSIS ๐ŸŒˆ

okay so here's the entire menu of things this package can do. don't panic at the size, it's just... a lot of slay:

package require Tcl  ?8.5?

package require Tk  ?8.5?

package require Plotchart  ?2.4.0?

::Plotchart::createXYPlot w xaxis yaxis args

::Plotchart::createStripchart w xaxis yaxis args

::Plotchart::createTXPlot w timeaxis xaxis args

::Plotchart::createXLogYPlot w xaxis yaxis args

::Plotchart::createLogXYPlot w xaxis yaxis args

::Plotchart::createLogXLogYPlot w xaxis yaxis args

::Plotchart::createPolarPlot w radius_data args

::Plotchart::createWindrose w radius_data sectors

::Plotchart::createIsometricPlot w xaxis yaxis stepsize

::Plotchart::createHistogram w xaxis yaxis args

::Plotchart::create3DPlot w xaxis yaxis zaxis args

::Plotchart::create3DRibbonPlot w yaxis zaxis

::Plotchart::createPiechart w

::Plotchart::createSpiralPie w

::Plotchart::createRadialchart w names scale style

::Plotchart::createBarchart w xlabels yaxis noseries args

::Plotchart::createHorizontalBarchart w xaxis ylabel noseries

::Plotchart::create3DBarchart w yaxis nobars

::Plotchart::create3DRibbonChart w names yaxis zaxis

::Plotchart::createBoxplot w xdata ydata orientation

::Plotchart::createTimechart w time_begin time_end args

::Plotchart::createGanttchart w time_begin time_end args

::Plotchart::createRightAxis w_or_plot yaxis

::Plotchart::createTableChart w columns ?widths?

::Plotchart::createTernaryDiagram w args

::Plotchart::createNormalPlot w xscale args

::Plotchart::createStatusTimeline w xaxis ylabel args

$anyplot title text position

$anyplot subtitle text

$anyplot canvas

$anyplot saveplot filename args

$anyplot xtext text

$anyplot ytext text

$anyplot vtext text

$anyplot xsubtext text

$anyplot ysubtext text

$anyplot vsubtext text

$anyplot xconfig -option value ...

$anyplot yconfig -option value ...

$anyplot background part colour_or_image dir ?brightness?

$anyplot xticklines colour ?dash?

$anyplot yticklines colour ?dash?

$anyplot legend series text ?spacing?

$anyplot removefromlegend series

$anyplot legendconfig -option value ...

$anyplot balloon x y text dir

$anyplot balloonconfig args

$anyplot plaintext x y text dir

$anyplot plaintextconfig args

$anyplot object itemtype series args

$anyplot deletedata

$xyplot plot series xcrd ycrd

$normalplot plot series mean stdev data

$normalplot diagonal

$xyplot plotlist series xlist ylist every

$xyplot region series xlist ylist

$xyplot minmax series xcrd ymin ymax

$histogram plotcumulative series xcrd ycrd

$xyplot trend series xcrd ycrd

$xyplot rchart series xcrd ycrd

$xyplot interval series xcrd ymin ymax ?ycentr?

$xyplot box-and-whiskers series xcrd ycrd

$xyplot vector series xcrd ycrd ucmp vcmp

$xyplot vectorconfig series -option value ...

$xyplot dot series xcrd ycrd value

$xyplot dotconfig series -option value ...

$xyplot contourlines xcrd ycrd values ?classes?

$xyplot contourlinesfunctionvalues xvec yvec valuesmat ?classes?

$xyplot contourfill xcrd ycrd values ?classes?

$xyplot contourbox xcrd ycrd values ?classes?

$xyplot colorMap colours

$xyplot legendisolines values classes

$xyplot legendshades values classes

$xyplot grid xcrd ycrd

$xyplot xband ymin ymax

$xyplot yband xmin xmax

$xyplot labeldot x y text orient

$polarplot plot series radius angle

$windrose plot data colour

$plot3d plotfunc function

$plot3d plotfuncont function contours

$plot3d gridsize nxcells nycells

$plot3d plotdata data

$plot3d interpolatedata data contours

$plot3d colour fill border

$plot3d ribbon yzpairs

$plot3d plot yzpairs

$xyplot dataconfig series -option value ...

$pie plot data

$pie colours colour1 colour2 ...

$pie explode segment

$radial plot data colour thickness

$pie colours colour1 colour2 ...

$barchart plot series ydata colour ?dir? ?brightness?

$barchart config -option value ...

$barchart plot series xdata colour ?dir? ?brightness?

$barchart config -option value ...

$barchart plot label yvalue colour

$barchart config -option value ...

$ribbon line xypairs colour

$ribbon area xypairs colour

$boxplot plot series label values

$timechart period text time_begin time_end colour

$timechart addperiod time_begin time_end colour

$timechart milestone text time colour

$timechart addmilestone time colour

$timechart vertline text time colour

$timechart hscroll scrollbar

$timechart vscroll scrollbar

$ganttchart task text time_begin time_end completed

$ganttchart milestone text time colour

$ganttchart vertline text time

$ganttchart connect from to

$ganttchart summary text args

$ganttchart color keyword newcolor

$ganttchart font keyword newfont

$ganttchart hscroll scrollbar

$ganttchart vscroll scrollbar

$isoplot plot rectangle x1 y1 x2 y2 colour

$isoplot plot filled-rectangle x1 y1 x2 y2 colour

$isoplot plot circle xc yc radius colour

$isoplot plot filled-circle xc yc radius colour

$table row items

$table separator

$table formatcommand procname

$table cellconfigure args

$ternary plot series xcrd ycrd zcrd text dir

$ternary line series coords

$ternary fill series coords

$ternary text xtext ytext ztext

$ternary ticklines colour

$timeline plot series item start stop color

$timeline vertline text time args

::Plotchart::viewPort w pxmin pymin pxmax pymax

::Plotchart::worldCoordinates w xmin ymin xmax ymax

::Plotchart::world3DCoordinates w xmin ymin zmin xmax ymax zmax

::Plotchart::coordsToPixel w x y

::Plotchart::coords3DToPixel w x y z

::Plotchart::polarCoordinates w radmax

::Plotchart::polarToPixel w rad phi

::Plotchart::pixelToCoords w x y

::Plotchart::pixelToIndex w x y

::Plotchart::determineScale xmin xmax inverted

::Plotchart::determineScaleFromList values inverted

::Plotchart::plotconfig charttype component property value

::Plotchart::plotstyle subcmd style args

::Plotchart::eraseplot anyplot

::Plotchart::createTargetDiagram w limits scale

$target plot series xvalues yvalues

::Plotchart::createPerformanceProfile w max

$performance plot series_and_data_pairs

::Plotchart::plotmethod charttype methodname plotproc

::Plotchart::plotpack w dir args

$anyplot bindplot event command args

$anyplot bindlast series event command

that's the whole vibe check right there ๐Ÿ‘‘ notice how it's all ::Plotchart::createSomething, then a bunch of $someplot dosomething calls โ€” that's the pattern, iykyk.


๐Ÿ’œ DESCRIPTION ๐Ÿ’œ

okay so Plotchart is a Tcl-only package, and its whole thing is making xy-plots, barcharts and all the other classic graphical presentations easy. like, ease of use over flexibility, that's the tradeoff it's making on purpose. the procs that create a plot use the entire canvas window, so the layout of your plot is completely automatic โ€” you don't gotta place a single thing โœจ

and the payoff? you get an entire xy-plot in, like, ten lines of code. no cap:

           package require Plotchart

           canvas .c -background white -width 400 -height 200
           pack   .c -fill both

           #
           # Create the plot with its x- and y-axes
           #
           set s [::Plotchart::createXYPlot .c {0.0 100.0 10.0} {0.0 100.0 20.0}]

           foreach {x y} {0.0 32.0 10.0 50.0 25.0 60.0 78.0 11.0 } {
               $s plot series1 $x $y
           }

           $s title "Data series"

ten lines. TEN. and it's already pretty ๐Ÿ˜ญ๐Ÿ’–

โš ๏ธ now the drawback, bestie, and we have to be honest about it: this package does no data management at all. so if the canvas holding the plot gets resized, you have to redraw the whole plot. that's the cost of admission ๐Ÿ™ˆ

but the advantage? it offers a whole lineup of plot and chart types:

  • XY-plots like the one shown above, with any number of data series. ๐Ÿ’…
  • Stripcharts โ€” a kind of XY-plot where the horizontal axis is adjusted automatically. the result is basically a sliding window on the data series. ๐ŸชŸ
  • Polar plots, where the coordinates are polar instead of cartesian. ๐Ÿงญ
  • Histograms, for plotting statistical information. ๐Ÿ“Š
  • Barcharts, piecharts, Gantt charts, time charts. ๐ŸŽ€
  • Isometric plots, where the scale of the coordinates in the two directions is always the same โ€” so a circle in world coordinates appears as a circle on the screen. ๐ŸŒ€
    • and you can zoom in and out, plus pan with these plots. (Note: this works best if no axes are drawn โ€” the zooming and panning routines do not distinguish the axes.) you do it with the mouse buttons together with the Ctrl key, and with the arrow keys together with the Ctrl key.
  • Piecharts, with automatic scaling to show the proportions. ๐Ÿฅง
  • Barcharts, with either vertical or horizontal bars, stacked bars, or bars side by side. ๐Ÿ“ˆ
  • Timecharts, where bars indicate a time period, and milestones or other important moments in time are represented by triangles. ๐Ÿ”บ
  • 3D plots (both for displaying surfaces and 3D bars). ๐ŸงŠ

now the lore drop ๐Ÿซถ, because this package has history:

with version 1.5 a new command showed up: plotconfig, which you can use to configure the plot options for particular types of plots and charts (cf. CONFIGURATION OPTIONS AND OTHER COMMANDS).

with version 1.8.3 several new features landed, which allow more interactivity (cf. INTERACTIVE USE).

with version 2.0 it became possible to put several plots or charts in one canvas. iconic behaviour, honestly ๐ŸŒŸ


๐ŸŽ€ PLOT CREATION COMMANDS ๐ŸŽ€

the whole system is: you create the plot or chart with one single command, and then you fill the plot with data. that's the flow, that's the ritual ๐Ÿงš

::Plotchart::createXYPlot w xaxis yaxis args

creates a new xy-plot (configuration type: xyplot). your classic, your starter Pokรฉmon ๐Ÿ’œ

  • widget w (in) โ€” name of the existing canvas widget that's gonna hold the plot.
  • list xaxis (in) โ€” a 3-element list containing minimum, maximum and stepsize for the x-axis, in that exact order. for an inverted axis, where the maximum appears on the left-hand side, you use: maximum, minimum and a negative stepsize. ๐Ÿซ 
  • list yaxis (in) โ€” a 3-element list containing minimum, maximum and stepsize for the y-axis, in that order. for an inverted axis, where the maximum appears at the bottom, you use: maximum, minimum and a negative stepsize.
  • list args (in) โ€” zero or more options that influence the appearance of the plot:

(bestie the option list is long and it's literally about to start, so keep scrolling โ€” we are so not done here ๐Ÿ’…โœจ)

  • -xlabels {labels} โ€” custom labels for the x-axis, bestie ๐ŸŽ€. If the labels are numeric, theyโ€™re positioned according to the given scale; otherwise theyโ€™re positioned with equal distance, based on the number of labels. Note: this only works if the stepsize of the xaxis argument is the empty string.
  • -ylabels {labels} โ€” similarly, custom labels for the y-axis. Same energy, y-axis edition ๐Ÿ’–.
  • -box {measures} โ€” see ARRANGING MULTIPLE PLOTS IN A CANVAS.
  • -axesbox {measures} โ€” see ARRANGING MULTIPLE PLOTS IN A CANVAS.
  • -timeformat format โ€” see USING DATE/TIME LABELS.
  • -gmt 0/1 โ€” see USING DATE/TIME LABELS.
  • -axestozero โ€” draw the axes at the origin (1), or at the sides of the plot area (0, default). This option is implemented for XY plots only.
  • -isometric โ€” rescale the axes so that a square in the coordinates appears as a square on the screen (1), or use the given extremes (0, default). This option is implemented for XY plots only.

::Plotchart::createStripchart w xaxis yaxis args

Create a new strip chart (configuration type: stripchart). The only difference to a regular XY plot is that the x-axis will be automatically adjusted when the x-coordinate of a new point exceeds the maximum.

  • widget w (in) โ€” name of the existing canvas widget to hold the plot.
  • list xaxis (in) โ€” a 3-element list containing minimum, maximum and stepsize for the x-axis, in this order. Note that an inverted x-axis is not supported for this type of plot.
  • list yaxis (in) โ€” a 3-element list containing minimum, maximum and stepsize for the y-axis, in this order. For an inverted axis, where the maximum appears at the bottom, use: maximum, minimum and a negative stepsize.
  • list args (in) โ€” zero or more options โ€” see the XY-plot for more information.

::Plotchart::createTXPlot w timeaxis xaxis args

Create a new time-x-plot (configuration type: txplot). The horizontal axis represents the date/time of the data and the vertical axis the values themselves.

  • widget w (in) โ€” name of the existing canvas widget to hold the plot.
  • list timeaxis (in) โ€” a 3-element list containing the minimum and maximum date/time to be shown and the stepsize (in days) for the time-axis, in this order. Note that an inverted time-axis is not supported.
  • list xaxis (in) โ€” a 3-element list containing minimum, maximum and stepsize for the vertical axis, in this order. For an inverted axis, where the maximum appears at the bottom, use: maximum, minimum and a negative stepsize.
  • list args (in) โ€” zero or more options โ€” see the XY-plot for more information.

::Plotchart::createXLogYPlot w xaxis yaxis args

Create a new xy-plot where the y-axis has a logarithmic scale (configuration type: xlogyplot).

The data should be given as for a linear scale, as the logarithmic transformation is taken of internally.

  • widget w (in) โ€” name of the existing canvas widget to hold the plot.
  • list xaxis (in) โ€” a 3-element list containing minimum, maximum and stepsize for the x-axis, in this order. For an inverted axis, where the maximum appears on the left-hand side, use: maximum, minimum and a negative stepsize.
  • list yaxis (in) โ€” a 2-element list containing minimum and maximum for the y-axis, in this order. Note that an inverted logarithmic axis is not supported.
  • list args (in) โ€” zero or more options โ€” see the XY-plot for more information.

::Plotchart::createLogXYPlot w xaxis yaxis args

Create a new xy-plot where the x-axis has a logarithmic scale (configuration type: logxyplot).

The data should be given as for a linear scale, as the logarithmic transformation is taken of internally.

  • widget w (in) โ€” name of the existing canvas widget to hold the plot.
  • list xaxis (in) โ€” a 2-element list containing minimum and maximum for the x-axis, in this order. Note that an inverted logarithmic axis is not supported.
  • list yaxis (in) โ€” a 3-element list containing minimum, maximum and stepsize for the y-axis, in this order. For an inverted axis, where the maximum appears on the left-hand side, use: maximum, minimum and a negative stepsize.
  • list args (in) โ€” zero or more options โ€” see the XY-plot for more information.

::Plotchart::createLogXLogYPlot w xaxis yaxis args

Create a new xy-plot where both the x-axis and the y-axis have a logarithmic scale (configuration type: logxlogyplot).

The data should be given as for a linear scale, as the logarithmic transformation is taken of internally.

  • widget w (in) โ€” name of the existing canvas widget to hold the plot.
  • list xaxis (in) โ€” a 2-element list containing minimum and maximum for the x-axis, in this order. Note that an inverted logarithmic axis is not supported.
  • list yaxis (in) โ€” a 2-element list containing minimum and maximum for the y-axis, in this order. Note that an inverted logarithmic axis is not supported.
  • list args (in) โ€” zero or more options โ€” see the XY-plot for more information.

::Plotchart::createPolarPlot w radius_data args

Create a new polar plot (configuration type: polarplot).

  • widget w (in) โ€” name of the existing canvas widget to hold the plot.
  • list radius_data (in) โ€” a 2-element list containing maximum radius and stepsize for the radial axis, in this order.
  • list args (in) โ€” zero or more options โ€” see the XY-plot for more information.

::Plotchart::createWindrose w radius_data sectors

Create a new windrose diagram. The diagram will consist of concentric circles as defined by the radius_data argument and a number of sectors (given by the sectors argument). The sectors are drawn in the โ€œnauticalโ€ convention, that is: the first is located at the positive y-axis, the second is to the right and so on in a clockwise direction.

  • widget w (in) โ€” name of the existing canvas widget to hold the diagram.
  • list radius_data (in) โ€” a 2-element list, the first element is the maximum radius, the second is the step to be used for the circles.
  • int sectors โ€” number of sectors to use (defaults to 16).

::Plotchart::createIsometricPlot w xaxis yaxis stepsize

Create a new isometric plot, where the vertical and the horizontal coordinates are scaled so that a circle will truly appear as a circle (configuration type: isometric).

  • widget w (in) โ€” name of the existing canvas widget to hold the plot.
  • list xaxis (in) โ€” a 2-element list containing minimum, and maximum for the x-axis, in this order.
  • list yaxis (in) โ€” a 2-element list containing minimum, and maximum for the y-axis, in this order.
  • float|noaxes stepsize (in) โ€” either the stepsize used by both axes or the keyword noaxes to signal the plot that it should use the full area of the widget, to not draw any of the axes.

::Plotchart::createHistogram w xaxis yaxis args

Create a new histogram (configuration type: histogram).

  • widget w (in) โ€” name of the existing canvas widget to hold the plot.
  • list xaxis (in) โ€” a 3-element list containing minimum, maximum and stepsize for the x-axis, in this order.
  • list yaxis (in) โ€” a 3-element list containing minimum, maximum and stepsize for the y-axis, in this order.
  • list args (in) โ€” zero or more options โ€” see the XY-plot for more information.

::Plotchart::create3DPlot w xaxis yaxis zaxis args

Create a new 3D plot.

  • widget w (in) โ€” name of the existing canvas widget to hold the plot.
  • list xaxis (in) โ€” a 3-element list containing minimum, maximum and stepsize for the x-axis, in this order.
  • list yaxis (in) โ€” a 3-element list containing minimum, maximum and stepsize for the y-axis, in this order.
  • list zaxis (in) โ€” a 3-element list containing minimum, maximum and stepsize for the z-axis, in this order.
  • list args (in) โ€” optional list of options (keyword-value pairs). Currently supported: -xlabels to set the labels for the x-axis.

::Plotchart::create3DRibbonPlot w yaxis zaxis

Create a new 3D ribbon plot. It is a simplification of the full 3D plot and allows for the drawing of a ribbon only (the x-axis is dropped).

  • widget w (in) โ€” name of the existing canvas widget to hold the plot.
  • list yaxis (in) โ€” a 3-element list containing minimum, maximum and stepsize for the y-axis, in this order.
  • list zaxis (in) โ€” a 3-element list containing minimum, maximum and stepsize for the z-axis, in this order.

::Plotchart::createPiechart w

Create a new piechart (configuration type: piechart).

  • widget w (in) โ€” name of the existing canvas widget to hold the plot.

โœจ ::Plotchart::createSpiralPie w

okay so picture a piechart but make it spiral ๐ŸŒ€ โ€” this creates a brand-new "spiral pie" (configuration type: spiralpie), and it's literally just a variation on the ordinary piechart. The plot twist? The value scales the radius instead of the angle. And by default the data are sorted, so don't come for me when your slices get reordered ๐Ÿ’…

  • w (widget, in) โ€” name of the existing canvas widget that's gonna hold the plot.

๐ŸŒˆ ::Plotchart::createRadialchart w names scale style

Creates a new radial chart โ€” the data get drawn as a line connecting the spokes of the diagram (configuration type: radialchart). It's giving spiderweb but make it data ๐Ÿ•ธ๏ธโœจ

  • w (widget, in) โ€” name of the existing canvas widget to hold the plot.
  • names (list, in) โ€” the names for the spokes.
  • scale (float, in) โ€” scale value that determines the position of the data along the spokes.
  • style (string, in) โ€” style of the chart, and it's optional. Pick one of these bestie:
    • lines โ€” the default: draws the data as independent polylines.
    • cumulative โ€” draws the data as polylines where the data are accumulated.
    • filled โ€” draws the data as filled polygons where the data are accumulated.

๐Ÿงฎ ::Plotchart::createBarchart w xlabels yaxis noseries args

Creates a new barchart with vertical bars (configuration type: vertbars). The horizontal axis is gonna show the labels sitting in the xlabels argument, and noseries decides both how wide the bars are and the way the series get drawn. Two jobs, one argument, main character energy ๐Ÿ‘‘

If you pass the keyword stacked, the series get drawn stacked on top of each other. Otherwise, every series that's drawn gets shifted to the right.

The number of series also sets the bar width, so there's space for exactly that many bars. And here's the cute bit: pass a floating-point number like 2.2 instead of an integer like 2 and you get a small gap between the sets of bars โ€” how wide that gap is depends on the fractional part. math girlie behaviour fr ๐ŸŽ€

  • w (widget, in) โ€” name of the existing canvas widget to hold the plot.
  • xlabels (list, in) โ€” list of labels for the x-axis. Its length also determines the number of bars that will be plotted per series.
  • yaxis (list, in) โ€” a 3-element list containing minimum, maximum and stepsize for the y-axis, in this order.
  • noseries (int|stacked, in) โ€” the number of data series that will be plotted. This has to be an integer number greater than zero (if stacked is not used).
  • args (string, in) โ€” one or more key-value pairs defining the options. Specific to barcharts: -xlabelangle value, the angle under which the labels should be drawn. Defaults to 0 โ€” horizontal text. Obsessed with this one if your labels are fairly long ๐Ÿ’–

๐ŸŒธ ::Plotchart::createHorizontalBarchart w xaxis ylabel noseries

Creates a new barchart with horizontal bars (configuration type: horizbars). The vertical axis is gonna display the labels contained in the ylabels argument. The number of series given by noseries determines both the width of the bars and the way the series will be drawn.

If you pass the keyword stacked, the series get drawn stacked from left to right. Otherwise, each series that's drawn gets shifted upward. (Yes the synopsis above says ylabel โ€” that's what's written, and the argument down here is ylabels ๐Ÿ™ˆ)

  • w (widget, in) โ€” name of the existing canvas widget to hold the plot.
  • xaxis (list, in) โ€” a 3-element list containing minimum, maximum and stepsize for the x-axis, in this order.
  • ylabels (list, in) โ€” list of labels for the y-axis. Its length also determines the number of bars that will be plotted per series.
  • noseries (int|stacked, in) โ€” the number of data series that will be plotted. This has to be an integer number greater than zero (if stacked is not used).

๐ŸงŠ ::Plotchart::create3DBarchart w yaxis nobars

Creates a new barchart with 3D vertical bars (configuration type: 3dbars). The horizontal axis displays the labels per bar, and the number of bars given by nobars determines the position and the width of the bars. The colours can be varied per bar, which is a whole vibe ๐ŸŒˆ (Fun fact: this type of chart was inspired by the Wiki page on 3D bars by Richard Suchenwirth โ€” credit where credit's due ๐Ÿซถ)

  • w (widget, in) โ€” name of the existing canvas widget to hold the plot.
  • yaxis (list, in) โ€” a 3-element list containing minimum, maximum and stepsize for the y-axis, in this order.
  • nobars (int, in) โ€” the number of bars that will be plotted.

๐ŸŽ€ ::Plotchart::create3DRibbonChart w names yaxis zaxis

Creates a new "ribbon chart" (configuration type: 3dribbon). This is a chart where the data series are represented as ribbons in a three-dimensional axis system ๐ŸŽ—๏ธ Along the x-axis โ€” which is "into" the screen โ€” the names are plotted, each one representing a single series. The first plot command draws the furthest series, the second draws the series in front of that, and so on. layering, but make it data โœจ

  • w (widget, in) โ€” name of the existing canvas widget to hold the plot.
  • w (in) โ€” names of the series, plotted as labels along the x-axis. (no cap, the page says widget w again here โ€” the description is the part that matters ๐Ÿ’€)
  • yaxis (list, in) โ€” a 3-element list containing minimum, maximum and stepsize for the y-axis (drawn horizontally!), in this order.
  • zaxis (list, in) โ€” a 3-element list containing minimum, maximum and stepsize for the z-axis (drawn vertically), in this order.
  • nobars (int, in) โ€” the number of bars that will be plotted.

๐Ÿ“ฆ ::Plotchart::createBoxplot w xdata ydata orientation

Creates a new boxplot with horizontal or vertical boxes (box-and-whiskers) โ€” configuration type: boxplot ๐Ÿ“Š Depending on the orientation, the x- or the y-axis gets drawn with labels. And the boxes are drawn based on the raw data (check the plot subcommand for this type of plot, iykyk).

  • w (widget, in) โ€” name of the existing canvas widget to hold the plot.
  • xdata (list, in) โ€” this is either a 3-element list containing minimum, maximum and stepsize for the x-axis, in this order (when orientation is horizontal), or a list of labels for the x-axis (when orientation is vertical). The length of the label list also determines the number of boxes that can be plotted. Those labels are used in the plot subcommand too.
  • ydata (list, in) โ€” this is either a 3-element list containing minimum, maximum and stepsize for the y-axis, in this order (when orientation is vertical), or a list of labels for the y-axis (when orientation is horizontal). The length of the label list also determines the number of boxes that can be plotted. The labels are also used in the plot subcommand.
  • orientation (string, in) โ€” if given, "horizontal" or "vertical" determines the orientation of the boxes. This optional value (default: horizontal) also determines how the xdata and ydata arguments get interpreted. iconique ๐Ÿฆ‹

๐Ÿ•ฐ๏ธ ::Plotchart::createTimechart w time_begin time_end args

Creates a new timechart (configuration type: timechart). The time axis (= the x-axis) goes from time_begin to time_end, and the vertical spacing is determined by the number of items to plot.

  • w (widget, in) โ€” name of the existing canvas widget to hold the plot.
  • time_begin (string, in) โ€” the start time, given in a form that's recognised by the clock scan command (e.g. "1 january 2004").
  • time_end (string, in) โ€” the end time, given in a form that's recognised by the clock scan command (e.g. "1 january 2004").
  • args (arguments, in) โ€” the remaining arguments can be:
    • The expected/maximum number of items. This determines the vertical spacing. (If given, it must be the first argument after "time_end")
    • The keyword -barheight and the number of pixels per bar. This is an alternative method to determine the vertical spacing.
    • The keyword -ylabelwidth and the number of pixels to reserve for the labels at the y-axis.

๐Ÿ“… ::Plotchart::createGanttchart w time_begin time_end args

Creates a new Gantt chart (configuration type: ganttchart). The time axis (= the x-axis) goes from time_begin to time_end, and the vertical spacing is determined by the number of items to plot. Then, via the specific commands, you can add tasks and connections between the tasks ๐Ÿ”—

  • w (widget, in) โ€” name of the existing canvas widget to hold the plot.
  • time_begin (string, in) โ€” the start time, given in a form that's recognised by the clock scan command (e.g. "1 january 2004").
  • time_end (string, in) โ€” the end time, given in a form that's recognised by the clock scan command (e.g. "1 january 2004").
  • args (arguments, in) โ€” the remaining arguments can be:
    • The expected/maximum number of items. This determines the vertical spacing. (If given this way, it must be the first argument after "time_end")
    • The expected/maximum width of the descriptive text (roughly in characters โ€” for the actual space reserved for the text, it's assumed that a character is about ten pixels wide). Defaults to 20. (If given this way, it must be the second argument after "time_end").
    • The keyword -barheight and the number of pixels per bar. This is an alternative method to determine the vertical spacing.
    • The keyword -ylabelwidth and the number of pixels to reserve for the labels at the y-axis.
Heads up bestie: the order of those args matters a whole lot โ€” the item count only counts if it's first, and the label width only counts if it's second. Positional girlies only ๐Ÿ’…

::Plotchart::createRightAxis w_or_plot yaxis

Okay so bestie, this one is a little โœจquirkyโœจ. It makes you a plot command that uses a right axis instead of the left one (configuration type: inherited from the existing plot). But like โ€” the canvas widget has got to already contain an ordinary plot, because the horizontal axis and all the other properties get reused. ๐Ÿ’…

Fr fr: preferably use the plot command, okay? Because with multiple plots in a canvas (and also when you're redefining an existing plot!) the wrong geometry might get used. ๐Ÿ˜ญ Not the vibe.

So: to plot data using the right axis, use this new command. To plot data using the left axis, use the original plot command. Simple as that. ๐Ÿซถ

  • widget w_or_plot (in) โ€” Name of the existing canvas widget to hold the plot, or (preferably!) the plot command for the plot with the left axis.
  • list yaxis (in) โ€” A 3-element list containing minimum, maximum and stepsize for the y-axis, in this order. ๐ŸŽ€

::Plotchart::createTableChart w columns ?widths?

Create a command to draw a table, bestie. You can use a whole variety of commands to draw the actual rows of the table, but heads up โ€” the number of columns is fixed. (See TABLE CHARTS for an example โœจ)

  • widget w (in) โ€” Name of the canvas widget to hold the table.
  • list columns (in) โ€” The headers of the columns in the table. The number of elements determines the number of columns. Iconic.
  • list widths (in) โ€” If given, either a single value, the width in pixels for all columns, or for each column the width of that column. If not given, the table is spread out over the width of the canvas (minus the margins). Slay. ๐Ÿ’…

::Plotchart::createTernaryDiagram w args

Create a command to draw a ternary diagram (configuration type: ternary). You can draw individual (labelled) data points in the diagram, lines, and filled polygons. Lowkey iconic geometry. ๐Ÿ”บโœจ

  • widget w (in) โ€” Name of the canvas widget to hold the ternary diagram.
  • list args (in) โ€” Zero or more option-value pairs to influence the position and the appearance of the diagram. In addition to the positioning options (-box and -axesbox) the diagram supports: -fractions yes/no, to display numbers 0 to 1 instead of 0 to 100%, and -steps number to influence the number of labels along the three sides. ๐ŸŽ€

::Plotchart::createNormalPlot w xscale args

Create a command to draw a normal plot โ€” super useful for investigating whether a data set is normally distributed or not. If it is, the data will fall on or near the diagonal. So yeah, it's a specialised plotting procedure, iykyk. ๐Ÿฆ‹

Fun fact: the details of the plotting procedure have been adopted from the qqnorm in the "R" stats package and described on Wikipedia. Ngl, respect.

Heads up! Because the implementation of this plot type relies on the math::statistics package, it's only available if that package can be loaded. No package, no plot, periodt. ๐Ÿ˜ญ
  • widget w (in) โ€” Name of the canvas widget to hold the normal plot.
  • list xscale (in) โ€” A 3-element list containing minimum, maximum and stepsize for the x-axis in this order. The scaling of the y-axis is determined from that. Important: the scale is to be given in terms of the normalised data โ€” that is, 0 represents the mean of the data, 1 one standard deviation away from the mean, etc. ๐Ÿ’œ
  • list args (in) โ€” Zero or more option-value pairs to influence the position and the appearance of the plot โ€” see the XY-plot for more details.

::Plotchart::createStatusTimeline w xaxis ylabel args

Create a command to draw a so-called status timeline. Its layout is similar to a horizontal barchart, but the bars are drawn in different colours, each representing the status of the item as it varies over time (that's the horizontal axis, bestie ๐Ÿ•). It's giving "project tracker but make it fashion".

  • widget w (in) โ€” Name of the canvas widget to hold the ternary diagram. (Yes, that's what the original says โ€” we're just passing the info along, no cap ๐Ÿ™ˆ)
  • list xaxis (in) โ€” A 3-element list containing minimum, maximum and stepsize for the x-axis, in this order.
  • list ylabels (in) โ€” List of labels for the y-axis. Its length also determines the number of bars that will be plotted per series. ๐ŸŒˆ
  • list args (in) โ€” Zero or more option-value pairs to influence the position and the appearance of the diagram. In addition to the positioning options (-box and -axesbox) the diagram supports: -xaxis yes/no, to turn displaying the numeric labels on or off. โœจ

๐Ÿ’… PLOT METHODS ๐Ÿ’…

Okay so every single one of those creation commands from the last section returns the name of a new object command that you use to manipulate the plot or chart. The subcommands available to a chart command depend on the type of the chart โ€” different vibes, different powers. ๐Ÿงš

Here are the general subcommands for all types of charts. $anyplot is the command returned by the creation command:

$anyplot title text position

Specify the title of the whole chart. Give it main character energy. ๐Ÿ‘‘

  • string text (in) โ€” The text of the title to be drawn.
  • string position (in) โ€” The position of the title. The default position is "center", but you can alternatively use "left" or "right". You can use multiple titles with different positions โ€” stack 'em, bestie. ๐ŸŽ€

$anyplot subtitle text

Specify the subtitle of the whole chart. The little supporting actor that ate. โœจ

  • string text (in) โ€” The text of the subtitle to be drawn.

$anyplot canvas

Return the name of the canvas (or the alias if you use more than one plot within a canvas). Use this value for the coordinate transformations. ๐Ÿฆ‹

$anyplot saveplot filename args

Draws the plot into a file, using PostScript. Saving the moment, literally. ๐Ÿ“ธ

  • string filename (in) โ€” Contain the path name of the file to write the plot to.
  • list args (in) โ€” If the standard PostScript output is used, the option -plotregion can be specified to save the whole plot (value: bbox) regardless of what's visible in the window. The default (value: window) is to only plot the visible part of the plot.

Optionally you can specify the option -format "some picture format" to store the plot in a different file than a PostScript file. This, however, relies on the Img package to do the actual job.

Note: because the window holding the plot must be fully visible before Img can successfully grab it, it is raised first. On some systems โ€” for instance Linux with KDE โ€” raising a window is not done automatically, and instead you need to click on the window in the task bar. Similar things happen on Windows XP. ๐Ÿ˜ญ
There seems to be something wrong under some circumstances, so instead of waiting for the visibility of the window, the procedure simply waits two seconds. It is not ideal, but it seems to work better. ๐Ÿ’€

$anyplot xtext text

Specify the title of the (horizontal) x-axis, for those plots that have a straight x-axis.

  • string text (in) โ€” The text of the x-axis label to be drawn.

$anyplot ytext text

Specify the title of the (horizontal) y-axis, for those plots that have a straight y-axis. (Yes, "horizontal" โ€” that's what the original says, we're not fixing it, no cap ๐Ÿ™ˆ)

  • string text (in) โ€” The text of the y-axis label to be drawn.

$anyplot vtext text

Draw a vertical label to the y-axis. Ngl this one's a little picky:

Note: this requires Tk 8.6 or later โ€” for older versions it does nothing. ๐Ÿ’€
  • string text (in) โ€” Text to drawn to the y-axis.

$anyplot xsubtext text

Specify the subtext of the (horizontal) x-axis, for those plots that have a straight x-axis. This text is drawn below the primary text. It's giving layered. ๐ŸŽ€

Since this involves positioning the primary text and setting margins, you need to set the option "usesubtext" for the bottom axis via the plotstyle command. The relevant options are: usesubtext, subtextcolor and subtextfont.

  • string text (in) โ€” The secondary text of the x-axis label to be drawn.

$anyplot ysubtext text

Specify the subtext of the (vertical) y-axis, for those plots that have a straight y-axis. This text is drawn below the primary text, for both axes on the left and the right. โœจ

Since this involves positioning the primary text and setting margins, you need to set the option "usesubtext" for the left or right axis via the plotstyle command. The relevant options are: usesubtext, subtextcolor and subtextfont.

  • string text (in) โ€” The secondary text of the y-axis label to be drawn.

$anyplot vsubtext text

Specify the subtext of the (vertical) y-axis, for those plots that have a straight y-axis. This text is drawn to the right of the primary text, for both axes on the left and the right. ๐Ÿฆ‹

Since this involves positioning the primary text and setting margins, you need to set the option "usesubtext" for the left or right axis via the plotstyle command. The relevant options are: usevsubtext, vsubtextcolor and vsubtextfont. (Note the "v" to distinguish this option from the text at the top of a vertical axis that is drawn via $anyplot ytext or $anyplot ysubtext โ€” don't mix 'em up, bestie ๐Ÿ’…)

  • string text (in) โ€” The secondary (vertical) text of the y-axis label to be drawn.

$anyplot xconfig -option value ...

Set one or more configuration parameters for the x-axis. The following options are supported:

  • format fmt โ€” The format for the numbers along the axis.
  • ticklength length โ€” The length of the tickmarks (in pixels).
  • ticklines boolean โ€” Whether to draw ticklines (true) or not (false).
  • scale scale_data โ€” New scale data for the axis, i.e. a 3-element list containing minimum, maximum and stepsize for the axis, in this order.
โš ๏ธ Beware: setting this option will clear all data from the plot. Like, all of it. Gone. So don't do it casually, fr fr. ๐Ÿ˜ญ

$anyplot yconfig -option value ...

Set one or more configuration parameters for the y-axis. This method accepts the same options and values as the method xconfig. ๐Ÿซถ

๐ŸŒธ $anyplot background part colour_or_image dir ?brightness?

Sets the background of part of the plot. Yes bestie, you can absolutely redecorate. ๐Ÿ’…

  • string part โ€” which chunk of the plot we're painting: "axes" for the axes area, "plot" for the inner part. The exact interpretation depends on the type of plot. Two more possibilities, because of course there are:
    • image โ€” a predefined image gets loaded into the background of the plot.
    • gradient โ€” the background is coloured in different shades of the given colour. The dir argument says which direction the colour gets whiter.
  • string colour_or_image โ€” the colour for that part, or the name of the image when part is "image".
  • string dir โ€” the gradient's direction, one of: top-down, bottom-up, left-right or right-left.
  • string brightness โ€” whether the colour should become brighter (bright) or darker (dark). Defaults to bright.

๐Ÿฆ‹ $anyplot xticklines colour ?dash?

Draws vertical ticklines at each tick location. Lil vertical stripes, very chic.

  • string colour โ€” colour of the lines. Passing an empty colour ("") removes them again. Defaults to "black".
  • string dash โ€” optional, sets the dash pattern for the lines. Defaults to "lines". Possible values: lines, dots1, dots2, dots3, dots4, dots5. The actual effect depends on the platform, iykyk.

๐ŸŽ€ $anyplot yticklines colour ?dash?

Horizontal version of the above โ€” draws horizontal ticklines at each tick location.

  • string colour โ€” colour of the lines. Specifying an empty colour ("") removes them again. Defaults to "black".
  • string dash โ€” optional dash pattern. Defaults to "lines". Possible values: lines, dots1, dots2, dots3, dots4, dots5. The actual effect depends on the platform.

โœจ $anyplot legend series text ?spacing?

Adds an entry to the legend. The series determines which graphical symbol gets used. Side effect alert: the legend actually gets drawn. ๐Ÿ‘‘

  • string series โ€” name of the data series. This is what decides the colour of the line and the symbol (if any) that will be drawn.
  • string text โ€” the text drawn next to the line/symbol.
  • integer spacing โ€” optional, the vertical spacing between entries in pixels. Lowkey important: this spacing gets reused later.

๐Ÿ’€ $anyplot removefromlegend series

Removes an entry for a series from the legend and redraws it. Bye bestie ๐Ÿซถ

  • string series โ€” name of the data series to be removed.

๐ŸŒˆ $anyplot legendconfig -option value ...

Sets one or more options for the legend. Picture it: a rectangle with text and graphics inside. Very main character.

  • background colour โ€” colour of the background (default is white). Set it to the empty string for a transparent legend.
  • border colour โ€” colour of the border (default is black). Set to the empty string if you do not want a border.
  • canvas c โ€” draw the legend in a different canvas widget. This gives you the freedom to position the legend outside the actual plot. Iconic behaviour, honestly.
  • font font โ€” font used to draw the text next to the symbol.
  • legendtype type โ€” overrides the type of legend that's pre-defined for the current type of plot. May be one of: rectangle or line.
  • position corner โ€” position of the legend. May be one of: top-left, top-right, bottom-left or bottom-right. Default value is top-right.
  • spacing pixels โ€” vertical spacing between entries in the legend, in pixels. Default value is 10 pixels.
not the manpage hitting you with a stray "bottom-left or bottom-right." copy-paste moment ๐Ÿ˜ญ we're preserving the lore, don't come for me

๐Ÿ“ $anyplot balloon x y text dir

Adds balloon text to the plot (except for 3D plots โ€” they don't get balloons, sorry). The arrow will point to the given x- and y-coordinates. For xy-graphs and such, the coordinates are directly related to the axes; for vertical barcharts the x-coordinate is measured as the number of bars minus 1, and similar for horizontal barcharts.

  • float x โ€” X-coordinate of the point that the arrow of the balloon will point to.
  • float y โ€” Y-coordinate of the point that the arrow of the balloon will point to.
  • string text โ€” text to be drawn in the balloon.
  • string dir โ€” direction of the arrow, one of: north, north-east, east, south-east, south, south-west, west or north-west.

๐Ÿงš $anyplot balloonconfig args

Configures the balloon text for the plot. The new settings get used for the next balloon text.

  • font fontname โ€” font to be used for the text.
  • justify left|center|right โ€” way to justify multiline text.
  • textcolour colour โ€” colour for the text (synonym: textcolor).
  • background colour โ€” background colour for the balloon.
  • outline colour โ€” colour of the outline of the balloon.
  • margin value โ€” margin around the text, in pixels.
  • rimwidth value โ€” width of the outline of the balloon, in pixels.
  • arrowsize value โ€” length factor for the arrow, in pixels.

๐Ÿซถ $anyplot plaintext x y text dir

Adds plain text to the plot (except for 3D plots). The text is positioned at the given x- and y-coordinates. For xy-graphs and such, the coordinates are directly related to the axes; for vertical barcharts the x-coordinate is measured as the number of bars minus 1, and similar for horizontal barcharts.

  • float x โ€” X-coordinate of the text position.
  • float y โ€” Y-coordinate of the text position.
  • string text โ€” text to be drawn.
  • string dir โ€” anchor for the text, one of: north, north-east, east, south-east, south, south-west, west or north-west.

๐Ÿ’œ $anyplot plaintextconfig args

Configures the plain text annotation for the plot. The new settings get used for the next plain text.

  • font fontname โ€” font to be used for the text.
  • justify left|center|right โ€” way to justify multiline text.
  • textcolour colour โ€” colour for the text (synonym: textcolor).

๐Ÿ”ฅ $anyplot object itemtype series args

Draws a canvas item in the plot, where the coordinates are scaled using the coordinate system of the plot. On top of the standard canvas types, it also supports circles, dots and crosses.

Note: currently implemented for xy-plots, (vertical and horizontal) barcharts, and piecharts.
Note: to add an entry in the legend for the object, you can use the dataconfig subcommand with a type "rectangle". This will cause a rectangle to be shown.
  • string itemtype (in) โ€” name of a standard canvas item, or "circle", "dot" or "cross".
  • string series (in) โ€” the data series it belongs to, used for setting the default drawing options.
  • list args (in) โ€” list of coordinates and drawing options.

๐Ÿ’… $anyplot deletedata

Removes the lines, symbols and other graphical object associated with the actual data from the plot. Clean slate energy.

Note: currently implemented for xy-plots only.
Note: the existing options for data series and the legend entry are kept as they were.
Note: currently there are side effects if the canvas contains more than one plot. Watch out for that one, fr fr.

Note: the commands xconfig and yconfig are currently implemented only for XY-plots, and only the option -format has any effect.

๐Ÿ‘‘ For xy plots, stripcharts, histograms and time-x-plots:

โญ $xyplot plot series xcrd ycrd

Adds a data point to the plot.

  • string series (in) โ€” name of the data series the new point belongs to.
  • float xcrd (in) โ€” X-coordinate of the new point. (For time-x plots this must be valid date/time that can be read with the clock scan command.)
  • float ycrd (in) โ€” Y-coordinate of the new point.

๐ŸŒธ For normal plots:

๐ŸŽ€ $normalplot plot series mean stdev data

Plots the data set using the given mean and standard deviation.

Because you give the mean and standard deviation separately, the plot can be used for several data series or for adding to an existing data series. Flexible queen behaviour.

  • string series (in) โ€” name of the data series, used to determine the appearance.
  • float mean (in) โ€” assumed mean of the data set.
  • float stdev (in) โ€” assumed standard deviation of the data set.
  • list data (in) โ€” list of the data comprising the data set.

๐ŸŒˆ $normalplot diagonal

Draws a diagonal line, indicating the ideal normally distributed data set. The blueprint, the goals, the vision board. โœจ


๐Ÿฆ‹ For xy, x-log y, log-x-y, log-x-log-y plots there is the additional command plotlist, which is useful for plotting a large amount of data:

๐Ÿ’– $xyplot plotlist series xlist ylist every

Draws a series of data as a whole. If symbols are asked for, draw them only for every Nth data point.

  • string series (in) โ€” name of the data series the new line belongs to.
  • float xlist (in) โ€” list of X-coordinates for the data series.
  • float ycrd (in) โ€” list of Y-coordinates for the data series.
  • int every (in) โ€” optional argument stating how often a symbol (if any) should be drawn. If left out, use a simple heuristic: N = sqrt(number of data points).

Other commands for xy, x-log y, log-x-y, log-x-log-y plots are region and minmax to draw filled polygons:

๐ŸŒธ $xyplot region series xlist ylist

Okay so this one draws a filled polygon โ€” a whole region, bestie, not just a line. And how that region looks is 100% decided by the config of the series it belongs to: -fillcolour fills the polygon in, -colour handles the boundary (set that bad boy to {} if you literally do not want a boundary, periodt), and -width decides how thick that boundary is. ๐Ÿ’…

  • series โ€” string, in โ€” the name of the data series this new region is joining. It's giving "who do I belong to".
  • xlist โ€” float, in โ€” the list of X-coordinates for the region.
  • ycrd โ€” float, in โ€” the list of Y-coordinates for the region.

๐Ÿฆ‹ $xyplot minmax series xcrd ymin ymax

Draws a filled strip that shows a minimum and a maximum โ€” like a little ribbon of range, iconic honestly. Same deal as region: the series config runs the show. -fillcolour fills the polygon, -colour does the boundary (again, {} if you want zero boundary), and -width sets the boundary width. โœจ

And here's the cute part: ymin and ymax can both be empty, which gets you an extra vertex in the strip. If both are empty, a whole new strip gets started. For best results, specify the x-coordinate in ascending order โ€” no cap, it just looks better that way.

  • series โ€” string, in โ€” name of the data series this new min/max strip belongs to.
  • xcrd โ€” float, in โ€” the X-coordinate for the strip.
  • ymin โ€” float, in โ€” the minimum y-coordinate for the strip.
  • ymax โ€” float, in โ€” the maximum y-coordinate for the strip.

๐Ÿ“Š Note on histograms

So for histograms, the x-coordinate you hand over is interpreted as the x-coordinate of the right side of the bar (or of the line segment). The first bar starts at the y-axis on the left. ๐Ÿซถ And if you want to completely fill the range of the x-axis? You should draw a bar at the maximum x-coordinate. That's the trick, iykyk.

For histograms you can also use the plotcumulative command:

$histogram plotcumulative series xcrd ycrd

The arguments mean exactly the same as for the plot command, but โ€” plot twist โ€” the data get accumulated to the previous values. ๐Ÿ“ˆ


๐Ÿ’œ For xy plots:

๐Ÿ”ฅ $xyplot trend series xcrd ycrd

Draws or updates a trend line using all the data given so far. Main character energy, it just keeps building on itself.

  • series โ€” string, in โ€” name of the data series the trend line belongs to.
  • xcrd โ€” float, in โ€” X-coordinate of the new data point.
  • ycrd โ€” float, in โ€” Y-coordinate of the new data point.

โญ $xyplot rchart series xcrd ycrd

Draws data the exact same way as the plot method, but with two extra lines added that show the expected range of the data โ€” that's +/- 3*standard deviation, if you were wondering. ๐ŸŒˆ

  • series โ€” string, in โ€” name of the data series the data point belongs to.
  • xcrd โ€” float, in โ€” X-coordinate of the new data point.
  • ycrd โ€” float, in โ€” Y-coordinate of the new data point.

๐ŸŽ€ $xyplot interval series xcrd ymin ymax ?ycentr?

Adds a vertical error interval to the plot, drawn from ymin to ymax. And if you also pass the ycentr argument, a symbol gets drawn right at that position. Cute little error bar with a hat on. ๐Ÿ’–

  • series โ€” string, in โ€” name of the data series the interval belongs to.
  • xcrd โ€” float, in โ€” X-coordinate of the interval.
  • ymin โ€” float, in โ€” minimum y-coordinate of the interval.
  • ymax โ€” float, in โ€” maximum y-coordinate of the interval.
  • ycentr โ€” float, in โ€” y-coordinate to draw the symbol at (optional).

๐Ÿงš $xyplot box-and-whiskers series xcrd ycrd

Draws a box and whiskers in the plot. Okay so listen carefully, because the orientation depends on which argument is the list:

  • If xcrd is a list of several values and ycrd is a single value, you get a horizontal box โ€” and the quartiles come from the list of values inside xcrd.
  • If instead ycrd holds a list of several values and xcrd is a single value, you get a vertical box, with quartiles determined from ycrd.
Heads up bestie: there must be exactly one list of several values. Otherwise an error is reported, no exceptions. ๐Ÿ˜ญ

Now the options, all of them going to the dataconfig command:

  • -boxwidth โ€” sets the width (or height) of the box. Default: 10 pixels.
  • -whiskers โ€” decides where the whiskers go: extremes for the extreme values, IQR or iqr for 1.5 times the interquartile range, or none for not at all. And watch the case, because it matters: if the value is IQR (uppercase), extreme values are also shown โ€” from 1.5 to 3 times the IQR as dots, and above 3 times IQR as stars. โญ If the value is iqr (lowercase), no extreme values get shown. Default: IQR.
  • -whiskerwidth โ€” the thickness of the line that draws the whiskers. Default: 1 pixel.
  • -mediancolour โ€” the colour of the line used for the median inside the box. Default: same as -colour.
  • -medianwidth โ€” the thickness of the line that draws the median inside the box. Default: 1 pixel.

And the arguments:

  • series โ€” string, in โ€” name of the data series the box-and-whiskers belongs to.
  • xcrd โ€” float, in โ€” X-coordinate of the box, or a list of values.
  • ymin โ€” float, in โ€” Y-coordinate of the box, or a list of values.

The box ends at the 1st and 3rd quartile, while the whiskers by default span 1.5 IQR (interquartile range) out from the 1st and 3rd quartile. Slay. ๐ŸŽ€

๐Ÿฆ‹ $xyplot vector series xcrd ycrd ucmp vcmp

Draws a vector in the plot. And the vector can be given either as cartesian coordinates or as length/angle โ€” where the angle is in degrees, interpreted according to the mathematical convention or the nautical one. (Peep the vectorconfig subcommand for that. ๐Ÿ‘€)

  • series โ€” string, in โ€” name of the series the vector belongs to. This decides the appearance and the interpretation.
  • xcrd โ€” float, in โ€” X-coordinate of the point where the arrow appears.
  • ycrd โ€” float, in โ€” Y-coordinate of the point where the arrow appears.
  • ucmp โ€” float, in โ€” X-component, or the length of the vector.
  • ycentr โ€” float, in โ€” Y-component, or the angle of the vector.

๐Ÿ’… $xyplot vectorconfig series -option value ...

Set the vector drawing options for a particular series. Per-series customisation, we love to see it.

  • series โ€” string, in โ€” name of the series the vector belongs to.

The options can be one of the following:

  • colour โ€” the colour of the arrow. Default: black. Synonym: color.
  • scale value โ€” the scale factor used to convert the length of the arrow into a number of pixels. Default: 1.0.
  • centred onoff โ€” logical value saying whether the xy-coordinates are used as the start of the arrow or as the centre. Default: 0. Synonym: centered.
  • type keyword โ€” the interpretation of the vector components. Can be "cartesian" (default), in which case the x- and y-components are expected, "polar" (where the angle 0 coincides with the positive x-axis and 90 coincides with the positive y-axis), or "nautical" (where 0 is "north" and 90 is "east").

๐Ÿ“ $xyplot dot series xcrd ycrd value

Draws a dot in the plot. Its size and colour are determined by value and by the options set for the series it belongs to. (See the dotconfig subcommand. ๐Ÿ’–)

  • series โ€” string, in โ€” name of the series the dot belongs to. Determines size and colour.
  • xcrd โ€” float, in โ€” X-coordinate of the point where the arrow appears.
  • ycrd โ€” float, in โ€” Y-coordinate of the point where the arrow appears.
  • value โ€” float, in โ€” value determining size and colour.

๐Ÿ’€ $xyplot dotconfig series -option value ...

Set the dot drawing options for a particular series. Get your dots looking exactly how you want, honestly obsessed.

  • series โ€” string, in โ€” name of the series the dot belongs to.

The options can be one of the following:

  • colour โ€” the colour of the dot if no scaling is used, or if the value exceeds the last limit of the classes.
  • scale value โ€” the scale factor used to convert the value into the radius of the dot in pixels. Default: 1.0.
  • radius value โ€” the default radius of the dots, used if there's no scaling by value (in pixels). Default: 3.
  • scalebyvalue onoff โ€” determines whether the dots all have the same size or a size depending on the given value. Default: on.
  • outline onoff โ€” draws a black circle around the dot, or not. Default: on.
  • classes list โ€” sets the limits and the corresponding colours. For instance:
$xyplot series1 -classes {0 blue 1 green} -colour red

will cause a blue dot to be drawn for values smaller than 0, a green dot for values larger/equal 0 but lower than 1, and a red dot for values larger/equal 1. ๐ŸŒˆ

  • 3deffect onoff โ€” shows a highlight in the dots, to mimick a 3D effect. Default: off.

If there's no list of classes for that particular series, the dots get scaled by the value. And yes, you can combine colouring by value and scaling by value โ€” just set a list of classes and set the scalebyvalue option on. Best of both worlds, fr fr. โœจ

๐Ÿซถ $xyplot contourlines xcrd ycrd values ?classes?

Draws contour lines for the values given on the grid. The grid is defined by the xcrd and ycrd arguments โ€” and here's the vibe: xcrd (resp. ycrd) is expected to be a matrix, implemented as a list of lists, which gives the x-coordinates (resp. y-coordinates) of the grid cell corners. The function values are given at these corners. The number of rows in xcrd (resp. ycrd) is ny, and each row contains nx values, so the total number of values in xcrd (resp. ycrd) is nx * ny. The classes determine which contour lines get drawn. And if a value on one of the corners is missing, the contour lines in that cell will not be drawn. ๐Ÿ™ˆ

Entries in the legend are drawn via the legendisolines subcommand.

  • xcrd โ€” list, in โ€” list of lists, each value is an x-coordinate for a grid cell corner.

Okay so picking up right where we left off โ€” here's the rest of that argument list (the x one already got its moment last time, bestie ๐Ÿซถ):

  • list ycrd (in) โ€” list of lists, and every single value in there is an y-coordinate for a grid cell corner โœจ
  • list values (in) โ€” list of lists, each value being the value sitting at a grid cell corner
  • list classes (in) โ€” either a plain list of class values, or a list of lists with two elements each (inner list = the class value + the colour to use for it ๐ŸŽ€). If it's empty or straight-up missing, the classes get figured out automatically, no stress.
Note: the class values have to enclose the whole range of values. No cap. ๐Ÿ’€ Note: the xcrd argument is generally made of nypoints identical rows, while each row of ycrd is made with one single value.

๐ŸŒˆ $xyplot contourlinesfunctionvalues xvec yvec valuesmat ?classes?

Draw contour lines for the values given on the grid ๐Ÿ’… The grid is defined by the xvec and yvec arguments. Here xvec (resp. yvec) is a list of x-coordinates (resp. y-coordinates), and the number of values in xvec (resp. yvec) is the number of points in the x-coordinate (resp. y-coordinate). The function values are given at these corners, and the classes decide which contour lines actually get drawn. If a value on one of the corners is missing, the contour lines in that cell simply won't be drawn โ€” ghosted, honestly ๐Ÿ™ˆ

Legend entries are drawn via the legendisolines subcommand.

  • list xvec (in) โ€” list of x-coordinates in increasing order โฌ†๏ธ
  • list yvec (in) โ€” list of y-coordinates in increasing order โฌ†๏ธ
  • list valuesmat (in) โ€” list of ny lists of nx values, each value being the value at a grid cell corner. The total number of values in valuesmat is nx * ny.
  • list classes (in) โ€” list of class values, or a list of lists of two elements (each inner list = the class value and the colour to be used). If empty or missing, the classes are determined automatically.
Note: the class values must enclose the whole range of values. Periodt.

๐ŸŽจ $xyplot contourfill xcrd ycrd values ?classes?

Draw filled contours for the values given on the grid. (The use of this method is identical to the "contourlines" method โ€” same energy, more colour ๐Ÿซถ)

Legend entries are drawn via the legendshades subcommand.


๐ŸŸช $xyplot contourbox xcrd ycrd values ?classes?

Draw the cells as filled quadrangles, iconic. The colour is determined from the average of the values on all four corners โœจ

Legend entries are drawn via the legendshades subcommand.


๐ŸŒˆ $xyplot colorMap colours

Set the colours to be used with the contour methods. The argument is either a predefined colourmap (grey/gray, jet, hot or cool) or a list of colours. When selecting the colours for actually drawing the contours, the given colours will be interpolated (based on the HLS scheme) โ€” fancy, I know ๐Ÿ’…

  • list colours (in) โ€” list of colour names or colour values, or one of the predefined maps:
    • grey or gray: gray colours from dark to light ๐ŸŒซ๏ธ
    • jet: rainbow colours ๐ŸŒˆ
    • hot: colours from yellow via red to darkred ๐Ÿ”ฅ
    • cool: colours from cyan via blue to magenta ๐Ÿ’œ

๐Ÿ“ $xyplot legendisolines values classes

Add the contour classes to the legend as coloured lines, and the text indicates the values. Cute, informative, the whole package ๐ŸŽ€

  • list values (in) โ€” the list of values as used for the actual drawing. This argument is used only if the list of classes is empty.
  • list values (in) โ€” the list of classes as used for the actual drawing. (yes, the page labels this one list values too โ€” that's literally what it says, iykyk ๐Ÿ™ˆ)

๐ŸŸฆ $xyplot legendshades values classes

Add the contour classes to the legend as coloured rectangles, with the text indicating the values. Shady in the best way ๐Ÿซถ

  • list values (in) โ€” the list of values as used for the actual drawing. This argument is used only if the list of classes is empty.
  • list values (in) โ€” the list of classes as used for the actual drawing.

๐Ÿ•ธ๏ธ $xyplot grid xcrd ycrd

Draw the grid cells as lines connecting the (valid) grid points. Lowkey the most satisfying part of the whole thing, ngl โœจ

  • list xcrd (in) โ€” list of lists, each value is an x-coordinate for a grid cell corner
  • list ycrd (in) โ€” list of lists, each value is a y-coordinate for a grid cell corner

๐ŸŒซ๏ธ $xyplot xband ymin ymax

Draw a light grey band in the plot, ranging over the full x-axis. Can be used to indicate a "typical" range for the data โ€” it's giving subtle but meaningful ๐Ÿ’…

  • float ymin (in) โ€” lower bound for the band
  • float ymax (in) โ€” upper bound for the band

๐ŸŒซ๏ธ $xyplot yband xmin xmax

Draw a light grey band in the plot, ranging over the full y-axis. Also great for indicating a "typical" range for the data ๐ŸŽ€

  • float xmin (in) โ€” lower bound for the band
  • float xmax (in) โ€” upper bound for the band

๐Ÿ“ $xyplot labeldot x y text orient

Draw a label and a symbol in the plot, with the label appearing near the symbol. The label gets drawn in grey so it's not too conspicuous โ€” main character symbol, supporting-role label, we love a humble king ๐Ÿ‘‘

You can configure the appearance of the symbol by using the data series name "labeldot":

$w dataconfig labeldot -colour red -type symbol -symbol dot
  • float x (in) โ€” x-coordinate of the symbol to be drawn
  • float y (in) โ€” y-coordinate of the symbol to be drawn
  • string text (in) โ€” text for the label
  • string orient (in) โ€” optional orientation (one of w, e, n, s) defining the position of the label with respect to the symbol. Defaults to w (so the label appears left of the symbol).

๐Ÿงญ For polar plots:

๐ŸŒ€ $polarplot plot series radius angle

Add a data point to the polar plot. Spinny โœจ

  • string series (in) โ€” name of the data series the new point belongs to
  • float radius (in) โ€” radial coordinate of the new point
  • float angle (in) โ€” angular coordinate of the new point (in degrees)

๐ŸŒฌ๏ธ For wind rose diagrams:

๐ŸŒน $windrose plot data colour

Draw the data contained in the data argument. The data are added to the existing spokes towards the outer circle โ€” she expands, she grows, she slays ๐Ÿ’…

  • list data (in) โ€” list of data (the length should correspond to the number of sectors)
  • string colour โ€” colour in which the new segments will be drawn

๐ŸงŠ For 3D plots:

๐Ÿ”๏ธ $plot3d plotfunc function

Plot a function defined over two variables x and y. The resolution is determined by the set grid sizes (check the gridsize method for more info) ๐Ÿ”

  • string function (in) โ€” name of the procedure that calculates the z-value for the given x and y coordinates. That procedure has to accept two float arguments (x is first, y is second) and return a floating-point value.

๐ŸŒˆ $plot3d plotfuncont function contours

Plot a function defined over two variables x and y, using the contour levels in contours to colour the surface. Resolution is again determined by the set grid sizes (see the gridsize method) โœจ

  • string function (in) โ€” name of the procedure that calculates the z-value for the given x and y coordinates. It has to accept two float arguments (x first, y second) and return a floating-point value.
  • list contours (in) โ€” list of values in ascending order that represent the contour levels (the boundaries between the colours in the contour map).

๐Ÿ“ $plot3d gridsize nxcells nycells

Set the grid size in the two directions. Together they determine how many polygons will be drawn for a function plot โ€” more cells, more polygons, more drama ๐ŸŒธ

  • int nxcells (in) โ€” number of grid cells in x direction. Has to be an integer number greater than zero.
  • int nycells (in) โ€” number of grid cells in y direction. Has to be an integer number greater than zero.
Don't try zero or negatives, bestie, it literally says greater than zero ๐Ÿ˜ญ

๐Ÿ—บ๏ธ $plot3d plotdata data

Plot a matrix of data ๐Ÿ“Š

  • list data (in) โ€” the data to be plotted. It has to be provided as a nested list with 2 levels. The outer list contains rows, drawn in y-direction, and each row is a list whose elements are drawn in x-direction, for the columns. Example:
set data {
{1.0 2.0 3.0}
{4.0 5.0 6.0}
}

๐Ÿงš $plot3d interpolatedata data contours

Plot the data using bilinear interpolation, with the contour levels in contours to colour the surface. The resolution is determined by the set grid sizes (see the gridsize method) ๐Ÿ’œ

  • list data (in) โ€” the data to be plotted, just as for the plotdata subcommand.
  • list contours (in) โ€” list of values in ascending order that represent the contour levels (the boundaries between the colours in the contour map).

๐ŸŽจ $plot3d colour fill border

Configure the colour to use for polygon borders and inner area.

Note: the "color" subcommand is a synonym. Both spellings, zero judgement ๐Ÿซถ
  • color fill (in) โ€” the colour to use for filling the polygons.
  • color border (in) โ€” the colour to use for the border of the polygons.

๐ŸŽ€ $plot3d ribbon yzpairs

Plot a ribbon based on the pairs of yz-coordinates. The colours for the ribbon itself and the edge are taken from the colours option โœจ

  • list yzpairs (in) โ€” list of pairs of yz-coordinates

๐ŸŽ—๏ธ For 3D ribbon plots:

$plot3d plot yzpairs

Plot a ribbon based on the pairs of yz-coordinates. The colours for the ribbon itself and the edge are taken from the colours option ๐Ÿฆ‹

  • list yzpairs (in) โ€” list of pairs of yz-coordinates

๐Ÿงฉ For xy plots, stripcharts, histograms, polar plots and ternary diagrams:

โš™๏ธ $xyplot dataconfig series -option value ...

Set the value for one or more options regarding the drawing of data of a specific series. Customise her, she deserves it ๐Ÿ’…

string series (in) โ€” the name of the data series whose configuration we are changing. ๐Ÿ’…

The following options are allowed:

  • colour c โ€” the colour to use when drawing the data series. ๐ŸŽจ
  • color c โ€” same thing, American spelling, still iconic. ๐ŸŽจ
  • type enum โ€” the drawing mode picked for the series. It can be one of line, symbol, or both.
  • symbol enum โ€” what kind of symbol to draw. This option is ignored when the drawing mode line was chosen. It can be one of plus, cross, circle, up (triangle pointing up), down (triangle pointing down), dot (filled circle), upfilled, or downfilled (filled triangles). โœจ
  • radius integer โ€” the size of the radius of the symbol. The total width of the symbol will be 2 times the radius size. The default radius is 4.
  • width integer โ€” the width of the line (if drawn) or the width of the polygon outline (if -filled).
  • filled enum โ€” whether to fill the area above or below the data line or not. Can be one of: no, up, or down (SPECIAL EFFECTS).
  • fillcolour colour โ€” colour to use when filling the area associated with the data line.
  • style enum โ€” the style to use for histograms:
    • filled: fill the area under the data points with bars (default)
    • spike: draw vertical lines from the y-axis (lower boundary) to the data point
    • symbol: draw a symbol at the data point
    • plateau: draw a horizontal line at the height of the data point
    • stair: draw a continuous stair-like line connecting the data points
  • smooth boolean โ€” (used with ternary diagrams) whether to draw the lines and filled polygons with the smooth option on (rounded corners) or not.

๐Ÿฅง For piecharts and spiral pies

  • $pie plot data โ€” fill a piechart. ๐Ÿฅง
    • list data (in) โ€” a list of pairs (labels and values). The values determine the relative size of the circle segments. The labels are drawn beside the circle.
  • $pie colours colour1 colour2 ... โ€” set the colours to be used. ๐ŸŒˆ
    • color colour1 (in) โ€” the first colour.
    • color colour2 (in) โ€” the second colour, and so on.
  • $pie explode segment โ€” explode a segment (that is: move one segment out of the circle). If the segment is indicated as auto, then you can click on a segment. This will be exploded instead of any previously exploded segment. ๐Ÿ’ฅ
    • int segment โ€” the segment to be exploded, or auto if you want to do this interactively.

๐ŸŒ€ For radial charts

  • $radial plot data colour thickness โ€” draw a new line in the radial chart.
    • list data (in) โ€” a list of data (one for each spoke). The values determine the distance from the centre of the line connecting the spokes.
    • color colour (in) โ€” the colour for the line.
    • int thickness (in) โ€” an optional argument for the thickness of the line.
  • $pie colours colour1 colour2 ... โ€” set the colours to be used. ๐ŸŒˆ
    • color colour1 (in) โ€” the first colour.
    • color colour2 (in) โ€” the second colour, and so on.

๐Ÿ“Š For vertical barcharts

  • $barchart plot series ydata colour ?dir? ?brightness? โ€” add a data series to a barchart. The bars are tagged with a tag data_\$series to identify them. ๐Ÿท๏ธ
    • string series (in) โ€” name of the series the values belong to.
    • list ydata (in) โ€” a list of values, one for each x-axis label.
    • color colour (in) โ€” the colour of the bars.
    • string dir (in) โ€” if given, top-down or bottom-up, to indicate the direction in which the colour changes. (If not given, a uniform colour is used.)
    • string brightness (in) โ€” if given, bright or dark (defaulting to bright). The colour will change to respectively white or black, depending on the direction.
  • $barchart config -option value ... โ€” set options for drawing the bars. โš™๏ธ
    • showvalues boolean โ€” whether to show the values or not (above the bars)
    • valuefont newfont โ€” name of the font to use for the values
    • valuecolour colour โ€” colour for the values
    • valueformat format โ€” format string to use for formatting the values

๐Ÿ“ˆ For horizontal barcharts

  • $barchart plot series xdata colour ?dir? ?brightness? โ€” add a data series to a barchart. The bars are tagged with a tag data_\$series to identify them. ๐Ÿท๏ธ
    • string series (in) โ€” name of the series the values belong to.
    • list xdata (in) โ€” a list of values, one for each y-axis label.
    • color colour (in) โ€” the colour of the bars.
    • string dir (in) โ€” if given, left-right or right-left, to indicate the direction in which the colour changes. (If not given, a uniform colour is used.)
    • string brightness (in) โ€” if given, bright or dark (defaulting to bright). The colour will change to respectively white or black, depending on the direction.
  • $barchart config -option value ... โ€” set options for drawing the bars. โš™๏ธ
    • showvalues boolean โ€” whether to show the values or not (to the right of the bars)
    • valuefont newfont โ€” name of the font to use for the values
    • valuecolour colour โ€” colour for the values
    • valueformat format โ€” format string to use for formatting the values

๐ŸงŠ For 3D barcharts

  • $barchart plot label yvalue colour โ€” add the next bar to the barchart. ๐Ÿงฑ
    • string label (in) โ€” the label to be shown below the column.
    • float yvalue (in) โ€” the value that determines the height of the column
    • color colour (in) โ€” the colour of the column.
  • $barchart config -option value ... โ€” set one or more configuration parameters. The following options are supported:
    • usebackground boolean โ€” whether to draw walls to the left and to the back of the columns or not
    • useticklines boolean โ€” whether to draw ticklines on the walls or not
    • showvalues boolean โ€” whether to show the values or not
    • labelfont newfont โ€” name of the font to use for labels
    • labelcolour colour โ€” colour for the labels
    • valuefont newfont โ€” name of the font to use for the values
    • valuecolour colour โ€” colour for the values

๐ŸŽ€ For 3D ribbon charts

  • $ribbon line xypairs colour โ€” plot the given xy-pairs as a ribbon in the chart. ๐ŸŽ€
    • list xypairs (in) โ€” the pairs of x/y values to be drawn (the series is drawn as a whole)
    • color colour (in) โ€” the colour of the ribbon.
  • $ribbon area xypairs colour โ€” plot the given xy-pairs as a ribbon with a filled area in front. The effect is that of a box with the data as its upper surface. ๐Ÿ“ฆ
    • list xypairs (in) โ€” the pairs of x/y values to be drawn (the series is drawn as a whole)
    • color colour (in) โ€” the colour of the ribbon/area.

๐Ÿซถ For boxplots

  • $boxplot plot series label values โ€” add a box-and-whisker to the plot. The dataconfig command can be used to customize the box-and-whisker (see the box-and-whiskers command for the xyplot for details). ๐Ÿซถ
    • string series (in) โ€” name of the data series the box belongs to
    • string label (in) โ€” the label along the x- or y-axis to which the data belong
    • list values (in) โ€” list of raw values, the extent of the box and the whiskers will be determined from this list.

โฐ For timecharts

  • $timechart period text time_begin time_end colour โ€” add a time period to the chart. โณ
    • string text (in) โ€” the text describing the period.
    • string time_begin (in) โ€” start time of the period.
    • string time_end (in) โ€” stop time of the period.
    • color colour (in) โ€” the colour of the bar (defaults to black).
  • $timechart addperiod time_begin time_end colour โ€” add a new period to the current row in the chart. This allows you to highlight several periods in the same row. No new text is drawn. โœจ
    • string time_begin (in) โ€” start time of the period.
    • string time_end (in) โ€” stop time of the period.
    • color colour (in) โ€” the colour of the bar (defaults to black).
  • $timechart milestone text time colour โ€” add a milestone (represented as a point-down triangle) to the chart. ๐Ÿ”ป
    • string text (in) โ€” the text describing the milestone.
    • string time (in) โ€” time at which the milestone must be positioned.
    • color colour (in) โ€” the colour of the triangle (defaults to black).
  • $timechart addmilestone time colour โ€” add another milestone to the current row in the chart. ๐Ÿ”ป
    • string time (in) โ€” time at which the milestone must be positioned.
    • color colour (in) โ€” the colour of the triangle (defaults to black).
  • $timechart vertline text time colour โ€” add a vertical line (to indicate the start of the month for instance) to the chart in the specified colour. ๐Ÿ“
    • string text (in) โ€” the text appearing at the top (an abbreviation of the date/time for instance).
    • string time (in) โ€” time at which the line must be positioned.
    • color colour (in) โ€” the colour of the line to be drawn (defaults to black)
  • $timechart hscroll scrollbar โ€” hooks a horizontal scrollbar up to your chart. peep the scrolling section for the whole story ๐Ÿ’…
    • widget scrollbar (in) โ€” the horizontal scrollbar getting connected to the chart
  • $timechart vscroll scrollbar โ€” same vibe but vertical: connects a vertical scrollbar to the chart. scrolling section, again, for the deets โœจ
    • widget scrollbar (in) โ€” the vertical scrollbar getting connected to the chart

๐Ÿซ For Gantt charts:

  • $ganttchart task text time_begin time_end completed โ€” adds a task to the chart with its time period and how done it is. returns a list of canvas items so you can keep messing with them later (connecting two tasks, etc.) ๐Ÿซถ
    • string text (in) โ€” the text describing the task
    • string time_begin (in) โ€” start time of the task
    • string time_end (in) โ€” stop time of the task
    • float completed (in) โ€” the percentage of the task that is completed
  • $ganttchart milestone text time colour โ€” drops a milestone into the chart, rendered as a point-down triangle ๐Ÿ”ป
    • string text (in) โ€” the text describing the milestone
    • string time (in) โ€” time at which the milestone must be positioned
    • color colour (in) โ€” the colour of the triangle (defaults to black)
  • $ganttchart vertline text time โ€” adds a vertical line to the chart (think: marking the start of a month, iykyk) ๐Ÿ“
    • string text (in) โ€” the text appearing at the top (an abbreviation of the date/time for instance)
    • string time (in) โ€” time at which the line must be positioned
  • $ganttchart connect from to โ€” adds an arrow linking the from task to the to task ๐Ÿ”—
    • list from (in) โ€” the list of items returned by the "task" command that represents the task from which the arrow starts
    • string text (in) โ€” the text summarising the tasks
    • list args (in) โ€” one or more tasks (the lists returned by the "task" command). they are shifted down to make room for the summary
    • list to (in) โ€” the list of items returned by the "task" command that represents the task at which the arrow ends
  • $ganttchart summary text args โ€” adds a summary item spanning all the tasks you list. graphically it's a thick bar running from the leftmost task to the rightmost ๐ŸŽ€
    • string text (in) โ€” the text summarising the tasks
    • list args (in) โ€” one or more tasks (the lists returned by the "task" command). they are shifted down to make room for the summary
โš ๏ธ bestie, use this command before connecting the tasks, because the arrow would not be shifted down!
  • $ganttchart color keyword newcolor โ€” sets the colour of a part of the Gantt chart. these colours hold for all items of that type, no cap ๐ŸŽจ
    • string keyword (in) โ€” tells you which part of the Gantt chart to change:
      • description โ€” the colour of the descriptive text
      • completed โ€” the colour of the filled bar representing the completed part of a task
      • left โ€” the colour for the part that is not yet completed
      • odd โ€” the background colour for the odd entries
      • even โ€” the background colour for the even entries
      • summary โ€” the colour for the summary text
      • summarybar โ€” the colour for the bar for a summary
    • string newcolor (in) โ€” the new colour for the chosen items
  • $ganttchart font keyword newfont โ€” sets the font of a part of the Gantt chart. these fonts hold for all items of that type โœ๏ธ
    • string keyword (in) โ€” tells you which part of the Gantt chart to change:
      • description โ€” the font used for descriptive text
      • summary โ€” the font used for summaries
      • scale โ€” the font used for the time scale
    • string newfont (in) โ€” the new font for the chosen items
  • $ganttchart hscroll scrollbar โ€” connects a horizontal scrollbar to the chart. see also the section on scrolling ๐Ÿ’ซ
    • widget scrollbar (in) โ€” the horizontal scrollbar that is to be connected to the chart
  • $ganttchart vscroll scrollbar โ€” connects a vertical scrollbar to the chart. see also the section on scrolling ๐Ÿ’ซ
    • widget scrollbar (in) โ€” the vertical scrollbar that is to be connected to the chart

๐ŸงŠ For isometric plots (to be extended):

  • $isoplot plot rectangle x1 y1 x2 y2 colour โ€” plots the outlines of a rectangle ๐Ÿ“
    • float x1 (in) โ€” minimum x coordinate of the rectangle to be drawn
    • float y1 (in) โ€” minimum y coordinate of the rectangle
    • float x2 (in) โ€” maximum x coordinate of the rectangle to be drawn
    • float y2 (in) โ€” maximum y coordinate of the rectangle
    • color colour (in) โ€” the colour of the rectangle
  • $isoplot plot filled-rectangle x1 y1 x2 y2 colour โ€” plots a rectangle filled with the given colour, fully slay ๐ŸŽจ
    • float x1 (in) โ€” minimum x coordinate of the rectangle to be drawn
    • float y1 (in) โ€” minimum y coordinate of the rectangle
    • float x2 (in) โ€” maximum x coordinate of the rectangle to be drawn
    • float y2 (in) โ€” maximum y coordinate of the rectangle
    • color colour (in) โ€” the colour of the rectangle
  • $isoplot plot circle xc yc radius colour โ€” plots the outline of a circle โญ•
    • float xc (in) โ€” x coordinate of the circle's centre
    • float yc (in) โ€” y coordinate of the circle's centre
    • color colour (in) โ€” the colour of the circle
  • $isoplot plot filled-circle xc yc radius colour โ€” plots a circle filled with the given colour ๐Ÿ’–
    • float xc (in) โ€” x coordinate of the circle's centre
    • float yc (in) โ€” y coordinate of the circle's centre
    • color colour (in) โ€” the colour of the circle

๐Ÿงพ For tables you can use the following subcommands:

  • $table row items โ€” draws a single row of items. the look of the items can be controlled explicitly via the format command โœจ
    • list items (in) โ€” list of text items to be drawn, one per column
  • $table separator โ€” draws a horizontal line to separate two rows โž–
  • $table formatcommand procname โ€” sets the procedure that controls the formatting of items. by default items are simply drawn as centered text ๐ŸŽ€
    • string procname (in) โ€” name of the procedure to be used. its signature is:
proc procname {table widget row column value} {...}

use the cellconfigure subcommand to set the attributes per cell

  • $table cellconfigure args โ€” sets the attributes for the next cell(s) to be drawn ๐Ÿ–Œ๏ธ
    • list args (in) โ€” key-value pairs: -background sets the background colour of the cells, -cell sets the foreground colour, -font sets the text font, -anchor sets the position of the text within the cell and -justify controls the layout of multiline text

๐Ÿ”บ For ternary diagrams you can use the following subcommands:

  • $ternary plot series xcrd ycrd zcrd text dir โ€” draws a single data point with a label. the three coordinates get scaled so a unique point in the triangle results, and a label goes right next to it ๐Ÿ“
    • string series (in) โ€” name of the data series the point belongs to (used to determine colour and symbol)
    • float xcrd (in) โ€” x-coordinate of the data point (refers to the lower-left corner)
    • float ycrd (in) โ€” y-coordinate of the data point (refers to the lower-right corner)
    • float zcrd (in) โ€” z-coordinate of the data point (refers to the top corner)
    • string text (in) โ€” label describing the data point
    • string dir (in) โ€” optional string indicating the direction in which to plot the label (e, n, etc.)
  • $ternary line series coords โ€” draws a continuous line based on the given coordinates (triplets) ใ€ฐ๏ธ
    • string series (in) โ€” name of the data series the line belongs to (used to determine colour and smoothness)
    • list coords (in) โ€” the coordinates of the points that determine the line (note that a point is defined by three coordinates)
  • $ternary fill series coords โ€” draws a filled polygon based on the given coordinates (triplets) ๐ŸŽจ
    • string series (in) โ€” name of the data series the polygon belongs to (used to determine colour and smoothness)
    • list coords (in) โ€” the coordinates of the points that determine the polygon (note that a point is defined by three coordinates)
  • $ternary text xtext ytext ztext โ€” draws text at the three corners of the diagram so you know which component is which ๐Ÿ”ค
    • string xtext (in) โ€” text to be plotted at the lower-left corner
    • string ytext (in) โ€” text to be plotted at the lower-right corner
    • string ztext (in) โ€” text to be plotted at the top corner
  • $ternary ticklines colour โ€” draws ticklines so reading values off the diagram is actually doable ๐Ÿ“Š
    • string colour (in) โ€” optional argument used as the colour of the ticklines. defaults to grey

โฑ๏ธ For status timeline plots you can use the following subcommands:

  • $timeline plot series item start stop color โ€” draws a bar in the given colour from start to stop for the item item. the item is a convenient label โ€” there is no relation to the labels along the axis, fr fr. items are drawn from bottom to top ๐ŸŒˆ

$timeline vertline text time args โ€” drops a vertical line to mark a moment that matters โœจ

  • string text (in) โ€” the name/identifier for the moment, so you know what the line is about ๐Ÿ’–
  • float time (in) โ€” the X-coordinate (or time) where the line gets drawn
  • list args (in) โ€” extra optional args that get passed straight through to the create line subcommand of the underlying canvas ๐ŸŽ€ so you can set the colour or the line width of that vertical line, no cap

๐Ÿฆ‹ COORDINATE TRANSFORMATIONS ๐Ÿฆ‹

So besides all the commands that build plots and charts directly, there's a whole little squad of commands for converting world coordinates to pixels and back again ๐Ÿ”. They're giving translator energy. Here's the lineup:

::Plotchart::viewPort w pxmin pymin pxmax pymax โ€” sets the viewport for window w, bestie. Lowkey it's meant to be used together with ::Plotchart::worldCoordinates. ๐Ÿซถ

  • widget w (in) โ€” name of the window (canvas widget) in question
  • float pxmin (in) โ€” left-most pixel coordinate
  • float pymin (in) โ€” top-most pixel coordinate (and yeah, remember: the vertical pixel coordinate starts with 0 at the top! ๐Ÿ™ˆ)
  • float pxmax (in) โ€” right-most pixel coordinate
  • float pymax (in) โ€” bottom-most pixel coordinate

::Plotchart::worldCoordinates w xmin ymin xmax ymax โ€” sets the extreme world coordinates for window w. And listen โ€” the world coordinates do not need to be in ascending order (like, xmin can totally be larger than xmax, which is how you get a reversal of the x-axis ๐Ÿ’… iconic).

  • widget w (in) โ€” name of the window (canvas widget) in question
  • float xmin (in) โ€” X-coordinate to be mapped to left side of viewport
  • float ymin (in) โ€” Y-coordinate to be mapped to bottom of viewport
  • float xmax (in) โ€” X-coordinate to be mapped to right side of viewport
  • float ymax (in) โ€” Y-coordinate to be mapped to top side of viewport

::Plotchart::world3DCoordinates w xmin ymin zmin xmax ymax zmax โ€” the 3D glow-up of the above: sets the extreme three-dimensional world coordinates for window w. Same deal, the coordinates don't have to ascend (xmin bigger than xmax = reversed x-axis, slay ๐ŸŒˆ).

  • widget w (in) โ€” name of the window (canvas widget) in question
  • float xmin (in) โ€” X-coordinate to be mapped to front side of the 3D viewport
  • float ymin (in) โ€” Y-coordinate to be mapped to left side of the viewport
  • float zmin (in) โ€” Z-coordinate to be mapped to bottom of viewport
  • float xmax (in) โ€” X-coordinate to be mapped to back side of viewport
  • float ymax (in) โ€” Y-coordinate to be mapped to right side of viewport
  • float zmax (in) โ€” Z-coordinate to be mapped to top side of viewport

::Plotchart::coordsToPixel w x y โ€” hands you back a list of pixel coordinates valid for the given window ๐Ÿ‘‘

  • widget w (in) โ€” name of the canvas alias (as returned by [$anyplot canvas]) in question
  • float x (in) โ€” X-coordinate to be mapped
  • float y (in) โ€” Y-coordinate to be mapped

::Plotchart::coords3DToPixel w x y z โ€” same vibe, returns a list of pixel coordinates valid for the given window โœจ

  • widget w (in) โ€” name of the canvas alias (as returned by [$anyplot canvas]) in question
  • float x (in) โ€” X-coordinate to be mapped
  • float y (in) โ€” Y-coordinate to be mapped
  • float y (in) โ€” Z-coordinate to be mapped
okay bestie, not me reading that last one ๐Ÿ’€ the page literally says float y again there, but the description is Z-coordinate. Typo moment, but I'm keeping it exactly as written so nothing gets lost ๐Ÿ™ˆ

::Plotchart::polarCoordinates w radmax โ€” sets the extreme polar coordinates for window w. The angle always runs from 0 to 360 degrees and the radius starts at 0, so all you gotta give is the maximum radius ๐ŸŽฏ important note: if the viewport is not square, this procedure will not adjust the extremes, so you'd end up with an elliptical plot. (The creation routine for a polar plot always determines a square viewport, so, y'know, iykyk ๐ŸŒธ)

  • widget w (in) โ€” name of the canvas alias (as returned by [$anyplot canvas]) in question
  • float radmax (in) โ€” maximum radius

::Plotchart::polarToPixel w rad phi โ€” just a wrapper for a call to ::Plotchart::coordsToPixel. โš ๏ธ Note: this procedure has been deprecated โ€” you should use ::Plotchart::coordsToPixel instead, fr fr.

  • widget w (in) โ€” name of the canvas alias (as returned by [$anyplot canvas]) in question
  • float rad (in) โ€” radius of the point
  • float phi (in) โ€” angle to the positive x-axis

::Plotchart::pixelToCoords w x y โ€” the reverse trip ๐Ÿฆ‹ returns a list of world coordinates valid for the given window.

  • widget w (in) โ€” name of the canvas alias (as returned by [$anyplot canvas]) in question
  • float x (in) โ€” X-pixel to be mapped
  • float y (in) โ€” Y-pixel to be mapped

::Plotchart::pixelToIndex w x y โ€” returns the index of the pie segment containing the pixel coordinates (x,y) ๐Ÿ“

  • widget w (in) โ€” name of the canvas alias (as returned by [$anyplot canvas]) in question, holding a piechart
  • float x (in) โ€” X-pixel to be mapped
  • float y (in) โ€” Y-pixel to be mapped

And on top of all that, there's a routine for getting "pretty" numbers to use with an axis ๐Ÿ‘‘

::Plotchart::determineScale xmin xmax inverted โ€” determines "pretty" numbers from the given range and returns a list containing the minimum, maximum and stepsize that can be used for a (linear) axis โœจ

  • float xmin (in) โ€” rough minimum value for the scaling
  • float xmax (in) โ€” rough maximum value for the scaling
  • boolean inverted (in) โ€” optional argument: if 1, then the returned list produces an inverted axis. Defaults to 0 (the axis will be from minimum to maximum)

::Plotchart::determineScaleFromList values inverted โ€” determines "pretty" numbers from the given list of values and returns a list containing the minimum, maximum and stepsize that can be used for a (linear) axis ๐ŸŽ€

  • float values (in) โ€” list of values that will be examined. May contain missing values (empty strings)
  • boolean inverted (in) โ€” optional argument: if 1, then the returned list produces an inverted axis. Defaults to 0 (the axis will be from minimum to maximum)

๐Ÿ’€ MISSING VALUES ๐Ÿ’€

Okay so real talk โ€” data that needs plotting is often full of gaps ๐Ÿ˜ญ like in a series of measurement data, the equipment could've failed, a sample wasn't collected correctly, or literally any of a million other reasons. Plotchart handles these gaps by assuming that one or both coordinates of such a data point are an empty string. Periodt. ๐Ÿ’…

#
# Create the plot with its x- and y-axes
#
set s [::Plotchart::createXYPlot .c {0.0 100.0 10.0} {0.0 100.0 20.0}]

foreach {x y} {0.0 32.0 10.0 {} 25.0 60.0 78.0 11.0 } {
    $s plot series1 $x $y
}

The effect varies depending on the type of plot, bestie:

  • For xy-plots, radial plots and strip charts, the missing data point causes a gap in the line through the points ๐ŸŒธ
  • For barchats, missing values are treated as if a value of zero was given
  • For time charts and Gantt charts, missing values cause errors โ€” there's just no use for them there ๐Ÿ™ˆ

๐ŸŒˆ OTHER OUTPUT FORMATS ๐ŸŒˆ

So besides output to the canvas on screen, the module is capable โ€” via canvas postscript โ€” of producing PostScript files โœจ and you might be wondering whether it's possible to extend this set of output formats, and the answer is literally "yes" ๐Ÿ’– This section tries to sum up the aspects of using this module for another sort of output.

One way you can create output files in a different format is by examining the contents of the canvas after everything has been drawn and rendering that contents in the right form. This is probably the easiest way, since it involves nothing more than re-creating all the elements in the plot that are already there ๐ŸŽ€

The drawback of that method? You need to have a display โ€” which is not always the case if you run a CGI server or something like that ๐Ÿ˜ญ

An alternative is to emulate the canvas command. For this to work you need to know which canvas subcommands are used and what for, so let's spill:

  • Obviously, the create subcommand is used to create the lines, texts and other items.
  • But the raise and lower subcommands are used too, because with these the module can influence the drawing order โ€” super important for simulating a clipping rectangle around the axes. (The routine DrawMask is responsible for this โ€” if the output format supports proper clipping areas, then a redefinition of this routine might just solve the whole thing ๐Ÿ‘‘)
  • Furthermore, the module uses the cget subcommand to find out the sizes of the canvas. A more mundane aspect of this: the module currently assumes that the text is 14 pixels high and that 80 pixels in width suffice for the axis' labels. No "hook" is provided to customise this ๐Ÿ™ˆ

In summary:

  • Emulate the create subcommand to create all the items in the correct format
  • Emulate the cget subcommand for the options -width and -height to allow the correct calculation of the rectangle's position and size
  • Solve the problem of raising and lowering the items so that they are properly clipped, for instance by redefining the routine DrawMask
  • Take care of the currently fixed text size properties

๐Ÿ’– SPECIAL EFFECTS ๐Ÿ’–

okay bestie, so if you wanna see what kind of special effects are possible, hereโ€™s an example: a plot where the area below the data line changes colour. iconic, honestly โœจ

canvas .c  -background white -width 400 -height 200
pack .c -fill both

set s [::Plotchart::createXYPlot .c {0.0 100.0 10.0} {0.0 100.0 20.0}]

$s background gradient green top-down

$s dataconfig series1 -filled up -fillcolour white

$s plot series1  0.0 20.0
$s plot series1 10.0 20.0
$s plot series1 30.0 50.0
$s plot series1 35.0 45.0
$s plot series1 45.0 25.0
$s plot series1 75.0 55.0
$s plot series1 100.0 55.0

$s plaintext 30.0 60.0 "Peak" south

The trick is literally this: fill the background with a colour that goes from green at the top to white at the bottom. Then fill the area above the data line with a white polygon. So the green shading changes with the height of the line. itโ€™s giving clever, no cap ๐ŸŽ€


๐ŸŒฑ ROOM FOR IMPROVEMENT ๐ŸŒฑ

ngl, in this version there are a lot of things that still need to be implemented:

  • More robust handling of incorrect calls โ€” right now the procedures may fail when theyโ€™re called incorrectly:
    • The axis drawing routines canโ€™t handle inverse axes right now.
    • If the user provides an invalid date/time string, the routines simply throw an error.

like, it works, but itโ€™s not fully bulletproof yet โ€” noted, bestie ๐Ÿ’…


๐Ÿ“ RESIZING ๐Ÿ“

Plotchart has not been designed to create plots and charts that keep track of the data that are put in. That means if an application needs to let the user resize the window holding the plot or chart, the app has to take care to redraw the complete plot.

Hereโ€™s a simple example of how to do that:

package require Plotchart

grid [canvas .c -background white] -sticky news
grid columnconfigure . 0 -weight 1
grid rowconfigure . 0 -weight 1

bind .c <Configure> {doResize}

proc doPlot {} {
    #
    # Clean up the contents (see also the note below!)
    #
    .c delete all

    #
    # (Re)draw the bar chart
    #
    set p [::Plotchart::createBarchart .c {x y z} {0 100 10} 3]
    $p plot R {10 30 40} red
    $p plot G {30 40 60} green
}

proc doResize {} {
    global redo

    #
    # To avoid redrawing the plot many times during resizing,
    # cancel the callback, until the last one is left.
    #
    if { [info exists redo] } {
        after cancel $redo
    }

    set redo [after 50 doPlot]
}
Please note: the code above will work fine for barcharts and many other types of plots, but as Plotchart keeps some private information for xy plots, more is needed in these cases. This actually requires a command "destroyPlot" to take care of such details. A next version of Plotchart may have that. ๐Ÿ˜ญ

Alternatively, you can use the xyplot package, which is built on top of Plotchart. This package supports zooming in and zooming out, as well as resizing the plot as a whole. Hereโ€™s a small demonstration program:

# xyplot_demo.tcl --
#     Demonstration of the xyplot package
#

package require xyplot

set xydata1 {}
set xydata2 {}
set xydata3 {}
set xydata4 {}
for { set i 0 } { $i < 1024 } { incr i } {
    lappend xydata1 [expr {$i-1000}] [expr {$i * sin($i/4096.0*3.1415*2) * (sin($i/256.0*3.1415*2))}]
    lappend xydata2 [expr {$i-1000}] [expr {$i * sin($i/4096.0*3.1415*2) * (sin($i/256.0*3.1415*2) + 0.25 * sin($i/256.0*3.1415*6))}]
    lappend xydata3 [expr {$i-1000}] [expr {$i * sin($i/4096.0*3.1415*2) * (sin($i/256.0*3.1415*2) + 0.25 * sin($i/256.0*3.1415*6) + 0.0625 * sin($i/256.0*3.1415*10))}]
    lappend xydata4 [expr {$i-1000}] [expr {$i * sin($i/4096.0*3.1415*2) * (sin($i/256.0*3.1415*2) + 0.25 * sin($i/256.0*3.1415*6) + 0.0625 * sin($i/256.0*3.1415*10) + 0.015625 * sin($i/256.0*3.1415*14))}]
}

set xyp [xyplot .xyp -xformat "%5.0f" -yformat "%5.0f" -title "XY plot testing" -background gray90]
pack $xyp -fill both -expand true

set s1 [$xyp add_data sf1 $xydata1 -legend "Serie 1 data" -color red]
set s2 [$xyp add_data sf2 $xydata2 -legend "Serie 2 data" -color green]
set s3 [$xyp add_data sf3 $xydata3 -legend "Serie 3 data" -color blue]
set s4 [$xyp add_data sf4 $xydata4 -legend "Serie 4 data" -color orange]

set xyp2 [xyplot .xyp2 -xticks 8 -yticks 4 -yformat %.2f -xformat %.0f]
pack $xyp2 -fill both -expand true

set s1 [$xyp2 add_data sf1 $xydata1]
set s2 [$xyp2 add_data sf2 $xydata2]
set s3 [$xyp2 add_data sf3 $xydata3]
set s4 [$xyp2 add_data sf4 $xydata4]

Zooming in is done by selecting a rectangle with the left mouse button pressed. Zooming out is done by pressing the right mouse button. If you resize the window, the canvases inside are resized too. If you zoom in, you can scroll the plot via the scrollbars that are automatically attached. slay, automatic scrollbars are such a vibe ๐ŸŒˆ


๐Ÿ” ZOOMING IN ๐Ÿ”

Since the Plotchart package does not keep track of the data itself, rescaling an existing plot โ€” for instance when zooming in โ€” would have to be done by redefining the plot and redrawing the data. But bestie, the canvas widget offers a way out by scaling and moving items, so zooming in becomes a bit simpler. we love a workaround โœจ

Whether zooming is actually useful depends on the type of plot. Currently it is defined for XY-plots only. The method is called "rescale" and it simply redraws the axes and scales and moves the data items so they conform to the new axes. The drawback is that any symbols are scaled by the same amount. The rescale method works best for plots that only have lines, not symbols. so like, lines? gorgeous. symbols? they get stretched too, fair warning ๐Ÿซถ

The method works very simply:

$p rescale {newxmin newxmax newxstep} {newymin newymax newystep}

โš™๏ธ CONFIGURATION OPTIONS AND OTHER COMMANDS โš™๏ธ

Okay bestie, this is the control room ๐Ÿ’…. The commands plotconfig and plotstyle can be used to set all manner of options. The command eraseplot can be used to completely erase a plot or chart. The syntax of these commands is:

::Plotchart::plotconfig charttype component property value

What plotconfig does: set a new value for the property of a component in a particular chart or plot type, or query its current value. Changed properties only have effect for the consecutive plots, not for the ones already created. Each argument is optional. ๐Ÿซถ

Note: the plotstyle command offers a more flexible way to control the configuration options.
  • charttype (string, in) โ€” the type of chart or plot (see the configuration type that is mentioned for each create command). If not given or empty, a list of chart types is returned. If it is given, the properties for that particular type are used.
  • component (string, in) โ€” the component of the plot/chart: leftaxis, rightaxis, background, margin and so on. If not given or empty, a list of components is returned. If it is given, the properties for that particular component will be set for that particular type of chart.
  • property (string, in) โ€” the property of the component of the plot/chart: textcolor, thickness of the axis line, etc. If not given or empty, a list of properties is returned. If it is given, that particular property for that particular component will be set for that particular type of chart.
  • value (string, in) โ€” the new value for the property. If empty, the current value is returned. If the value is "default", the default value will be restored.

Also note: in some cases an empty value is useful. Use "none" in this case โ€” it can be useful for colours and for formats. โœจ

::Plotchart::plotstyle subcmd style args

This one manipulates the style in which subsequent plots will be drawn. The default style is "default", but you can define and load any number of other styles. Iconic behavior, honestly ๐Ÿ‘‘

  • subcmd (string, in) โ€” the subcommand to be executed:
    • configure โ€” this subcommand allows you to set the options per chart type. It takes the same options as the plotconfig command.
    • current โ€” return the current style
    • load โ€” make the given style the active style for subsequent plots and charts
    • names โ€” return the list of currently defined styles
  • style (string, in) โ€” the name of the plot style to manipulate
  • args (list, in) โ€” the new options for the style. Each option is described by: chart type, component of the chart, property of the component and the new value for the property โ€” see the plotconfig command for details.

Below is a detailed list of the components and properties ๐Ÿ‘‡

  • Axes come in a wide variety:
    • leftaxis, rightaxis, topaxis, bottomaxis for the plots with a rectangular shape.
    • xaxis, yaxis and zaxis are used for the 3D plots
    • axis, this represents the radial and tangential axes of a polar plot
  • All axes have the following properties:
    • color โ€” the colour of the line and the tickmarks
    • thickness โ€” the width of the line of the axis itself, not the tickmarks
    • ticklength โ€” the length of the tickmarks in pixels. A positive value is outward, a negative value is inward.
    • font โ€” the font for the labels and the text at the axis
    • format โ€” the format for rendering the (numerical) labels. For the time axis it is the format for a date and time.
    • textcolor โ€” the colour for the labels and the text.
    • labeloffset โ€” space (in pixels) between the tickmark and the actual label
    • minorticks โ€” number of minor tickmarks between the major tickmarks
    • shownumbers โ€” show the numbers/labels or not.
    • showaxle โ€” show the axis line or not.
  • The margin is important for the layout. Currently only the rectangular plots allow the margins to be set: left, right, top and bottom. The values are in pixels. ๐Ÿ“
  • The text component is meant for any text appearing via the plaintext subcommand. The properties are: textcolor, font and anchor (positioning of the text relative to the given coordinates).
  • The background has two properties: outercolor, the colour outside of the actual plot, and innercolor, the colour inside the plot. (Note: only "outercolor" has now been implemented).
  • The mask has one property only: draw. If set to 1, the default, white rectangles are drawn to mimick the effects of clipping โ€” excess data are made invisible this way. Otherwise these rectangles are not drawn. This is useful to control the layout more tightly, for instance with multiple plots in one canvas.
  • The title component has the same properties as the text component (but it is independent of that component). It also has a background property: if not set (or set to the empty string) this is the same as the outercolor property of the background component, otherwise it is a separate colour.
  • The legend has three properties: background, border and position. See the legend subcommand for the meaning.
  • The bar components is used for all barchart-like plots and has three properties: barwidth (relative width of the bars in relation to the items along the axis), innermargin (the relative width of the gaps between bars or groups of bars) and the outline colour.
  • The labels component is used to describe the appearance of the labels of piecharts and "spiral" piecharts. The properties are:
    • textcolor โ€” colour of the label text
    • font โ€” font to be used for the label text
    • placement โ€” out of the circle or in the circle
    • sorted โ€” the data are sorted in ascending order first
    • shownumbers โ€” the labels are combined with the numbers according to the format
    • format โ€” the format to be used (defaults to: "%s (%g)") if the numbers are to be shown. The format command gets the label first, then the number)
    • formatright โ€” if given, the format to be used for labels and numbers appearing to the right of the pie. The format command gets the number first, then the label. (Defaults to "")
  • The slice component has properties to control the appearance of the sections in the pie diagram:
    • outline โ€” the colour of the line around the slices (default: black)
    • outlinewidth โ€” width of the line around the slices (default: 1 pixel)
    • startangle โ€” the angle w.r.t. positive x-axis where the first slice starts
    • direction โ€” the direction in which to draw the slices (default: +, that is clockwise)
  • The table charts use the general components title and margin and further more the specific components header, oddrow, evenrow, cell and frame:
    • header, oddrow and evenrow have the properties: background, font, color, height and anchor with obvious meanings.
    • The cell component defines in addition leftspace, rightspace and topspace for fine-grained control of the spacing inside the cell. These are not set via the cellconfigure subcommand however.
    • Finally the frame component uses color, outerwidth (for the width of the line surrounding the whole table) and innerwidth (for the width of lines separating columns and rows).
::Plotchart::eraseplot anyplot

Erase the plot/chart with all resources connected to it. Poof, gone, no trace ๐Ÿ’จ

  • anyplot (string, in) โ€” the plot/chart command. All canvas items associated with this command and all internal resources will be removed, including the plot/chart command itself.

See the examples in plotdemos7.tcl for its use. ๐Ÿงš

๐Ÿ’– SCROLLING FOR TIMECHARTS AND GANTT CHARTS ๐Ÿ’–

Okay so bestie, automatic scrolling management is a whole thing for exactly two plot types: timecharts and Gantt charts. The subcommands hscroll and vscroll associate (existing) scrollbars to the plot, in much the same way as for text and canvas widgets.

Once that association is made, the scrollbars are automatically updated if:

  • You add an item with a period wider than the current one.
  • You add a vertical line for a time beyond the current bounds.
  • You add an extra item beyond the number that was used to create the chart.

For instance, copy this exact vibe:

package require Plotchart

canvas .c -width 400 -height 200
scrollbar .y -orient vertical
scrollbar .x -orient horizontal

grid .c .y -sticky news
grid .x    -sticky news

source plotchart.tcl

set s [::Plotchart::createTimechart .c "1 january 2004"  "31 december 2004" 4]

$s period "Spring" "1 march 2004" "1 june 2004" green
$s period "Summer" "1 june 2004" "1 september 2004" yellow
$s vertline "1 jan" "1 january 2004"
$s vertline "1 apr" "1 april 2004"
$s vertline "1 jul" "1 july 2004"
$s vertline "1 oct" "1 october 2004"
$s vertline "1 jan" "1 january 2005"
$s vertline "1 apr" "1 april 2005"
$s vertline "1 jul" "1 july 2005"
$s milestone "Longest day" "21 july 2004"
$s milestone "Longest day 2" "21 july 2004"
$s milestone "Longest day 3" "21 july 2004"
$s milestone "Longest day 4" "21 july 2004"
$s milestone "Longest day 5" "21 july 2004"
$s milestone "Longest day 6" "21 july 2004"
$s title "Seasons (northern hemisphere)"

$s vscroll .y
$s hscroll .x

The original extent of the chart is from 1 january 2004 to 31 december 2004. But because of the addition of vertical lines in 2005 and more items than was specified at the creation of the chart, both the horizontal and the vertical scrollbar will be enabled. Slay. โœจ


๐Ÿฆ‹ SPECIALISED PLOTS ๐Ÿฆ‹

Most of the plot and chart types described above have a fairly general use, and you just prepare the data to be plotted yourself. This section describes several plot types that are more specialised, in the sense that they have specific purposes and you pass raw data that are then processed in the plotting routines.

Currently there are the following types:

  • Target diagrams are used to assess the capacity of numerical models to reproduce measurement data. They are described in detail in:

Jason K. Joliff et al. Summary diagrams for coupled hydrodynamic-ecosystem model skill assessment Journal of Marine Systems 76 (2009) 64-82 DOI: 10.1016/j.jmarsys.2008.05.014

  • Performance profiles are used for comparing the performance of numerical methods or implementations thereof with each other. For more information:

Desmond Higham and Nicholas Higham Matlab Guide SIAM, 2005, Philadephia

Most of the general methods for XY-plots work for these plots as well, but their creation and the methods to plot the data are very specific.

๐ŸŽฏ ::Plotchart::createTargetDiagram w limits scale

Create a new target diagram with circles indicating specific limits. The x-axis represents the unbiased "root-mean-square difference" (typically varying between -1 and 1) and the y-axis represents the normalised bias.

Data points closer to the origin represent better results than data points further away.

  • widget w (in) โ€” Name of the existing canvas widget to hold the plot.
  • list limits (in) โ€” List of radii for the circles that represent the limits (for instance: 0.5 and 0.7).
  • double scale (in) โ€” Scale for the axes โ€” defaults to 1, but if the model results are a poor fit, then that may be too small a value. Both axes are scaled in the same way.

๐Ÿ’… $target plot series xvalues yvalues

The plot method takes two series of data of the same length, the first one representing the model results, the second one representing the measurements or, more general, the data that need to be reproduced.

  • string series (in) โ€” Name of the series (it will be plotted as a symbol that is configured via the $target dataconfig command (see the XY-plot equivalent for an explanation)).
  • list xvalues (in) โ€” List of model results (missing values are represented as empty strings).
  • list yvalues (in) โ€” List of measured values (missing values are represented as empty strings; only if both the x and the y values are given, is the pair used in the computations).

๐Ÿ”ฅ ::Plotchart::createPerformanceProfile w max

Create a diagram to show the performance of various numerical methods (or solvers). The idea is to first run these methods on a set of problems and measure their performance. The smaller the number the better. Then these methods are compared via a so-called performance profile: the data are scaled and ordered, such that the best method ends up highest.

Because of the nature of the plot all data must be given at once.

  • widget w (in) โ€” Name of the existing canvas widget to hold the plot.
  • float max (in) โ€” Maximum value for the x-axis (the x-axis is the scaled performance of the series).

๐ŸŒˆ $performance plot series_and_data_pairs

Plot the data for each given method. The data are identified by the series name and the appearance is controlled via prior dataconfig subcommand.

  • list series_and_data_pairs (in) โ€” List of series names and data. All data must be given at once.

The command plotmethod can be used to add new methods for a particular plot or chart type. It is intended to help you develop specialised graphical displays.

๐Ÿงš ::Plotchart::plotmethod charttype methodname plotproc

Adds a new method for the given plot or chart type. The method is implemented by the command or procedure given in the plotproc argument. The procedure will be called with two extra arguments, the name of the created plot and the canvas widget that contains (see the example below).

  • string charttype (in) โ€” The type of plot or chart that the new method should be added to.
  • string methodname (in) โ€” Name of the method to be used.
  • string plotproc (in) โ€” Name of the command or procedure that implements the method.

Here is a trivial example of how to use this:

#
# The custom method "doodle" always adds the text "DOODLE"
# to the plot
#
proc doodle {p w x y} {
    $p plaintext $x $y "DOODLE"
}
::Plotchart::plotmethod xyplot doodle doodle

#
# Use it
pack [canvas .c]

set p [::Plotchart::createXYPlot .c {0 100 10} {0 20 5}]

$p doodle 40 10

๐Ÿ“ TABLE CHARTS ๐Ÿ“

To show what you can do with table charts, here is a simple example that plots a number of random data. The colours depend on the range that the data belong to. For this the procedure setColor is used.

package require Plotchart

pack [canvas .c -bg white -height 300] -fill both -expand yes

::Plotchart::plotconfig table frame outerwidth 3
::Plotchart::plotconfig table frame color red

set t [::Plotchart::createTableChart .c {"Column 1" "Column 2" "Column 3"} 80]

proc setColor {table widget row col value} {
    $table cellconfigure -background white -color black
    if { $value < 2.0 } {
        $table cellconfigure -background red -color white
    }
    if { $value > 6.0 } {
        $table cellconfigure -background green
    }

    return [format "%6.3f" $value]
}

# Command must already exist ...
$t formatcommand setColor

$t title "Demonstration of table charts"
$t separator

for {set i 0} {$i < 9} {incr i} {
    set row {}

    for {set j 0} {$j < 3} {incr j} {
        lappend row [expr {10.0 * rand()}]
    }

    if { $i == 3 } {
        $t separator
    }

    $t row $row
}

๐ŸŽ›๏ธ CONTROL DISPLAYS ๐ŸŽ›๏ธ

TODO


๐Ÿ’œ USING DATE/TIME LABELS ๐Ÿ’œ

The options -timeformat and -gmt are used to control the display of date/time labels along the x-axis for those plot types for which it makes sense. These options were implemented to take care of date/time labels for stripcharts, as you can also use custom labels (the option -xlabels) if the axis is "static". Since this is not the case for stripcharts, this was not an option (Tcllib/Tklib bug 3613718). The example below illustrates how to use the -timeformat option. The -gmt option merely suppresses the handling of daylight saving time by the [clock format] command.

package require Plotchart

pack [canvas .c -width 500 -bg white]

#
# Note that we need to present the x values as clock seconds
#
set start [clock scan  "0:00"]
set stop  [clock scan "10:00"]
set s [Plotchart::createStripchart .c [list $start $stop 7200] {0 10 1} -timeformat "%H:%M"]

foreach {x y} {0 0 2 5 5 2 9 9 12 10} {
    set x [expr {$start + 3600 * $x}] ;# Convert hour to clock seconds
    $s plot a $x $y
}

The plot subcommand simply interprets the x and y data as straightforward numbers, so that you need to do the conversion from date/time to "clock seconds" yourself. Ngl, that part is on you, bestie. ๐Ÿ˜Œโœจ

โœจ ARRANGING MULTIPLE PLOTS IN A CANVAS โœจ

Okay so sometimes you want several plots chilling in one canvas, and there's a whole command for that: plotpack copies the contents of a plot into another canvas widget. Heads up though โ€” this new canvas widget does not act as a composite plot, but bestie, it can be saved as a PostScript file for instance. ๐Ÿ’– And note: the command simply takes a snapshot of the plots/charts as they are at that moment (so like, a screenshot of the vibe, not a live link, iykyk).


::Plotchart::plotpack w dir args โ€” copy the contents of the plots/charts into another widget, in a manner similar to the pack geometry manager.

  • widget w (in) โ€” the name of the canvas widget to copy the plots/charts into
  • string dir (in) โ€” the direction of the arrangement โ€” top, left, bottom or right
  • list args (in) โ€” list of plots/charts to be copied

For example:

set p1 [createXYPlot ...]
set p2 [createBarchart ...]

... fill the plots ...

toplevel .t
pack [canvas .t.c2 -width ...]

#
# Copy the two plots above each other in the new canvas
#
plotpack .t.c2 top $p1 $p2

A different method is to use the -box and -axesbox options when creating the plot. These control the area in the canvas where the plot or chart will be drawn. ๐ŸŽ€

๐ŸŒธ the -box option

It takes as its value a list of four numbers:

  • X-coordinate of the upper-left corner of the area that will contain the plot or chart (simply a canvas coordinate)
  • Y-coordinate of the upper-left corner
  • Width of the area
  • Height of the area

Specifying the width and height makes it easier to reposition the area with respect to other plots. (Yes, you could just vibe it out with the coords, but the width/height glow-up is worth it. ๐Ÿ’…)

๐Ÿฆ‹ the -axesbox option

This one is meant to make aligning the axes of a plot with those of other plots easier. It takes a list of six arguments:

  • Identification of the plot with respect to which it should be positioned (the command returned by the creation command)
  • The anchor position that should be used (n, nw, ...)
  • X-coordinate of the upper-left corner of the area that will contain the plot or chart. This coordinates is taken relative to the anchor position
  • Y-coordinate of the upper-left corner
  • Width of the axis area
  • Height of the axis area

With this option the area the axes occupy is first determined and the complete area is derived from the margins. Very math, very demure. โœจ

For example:

set p2 [::Plotchart::createXYPlot .c {0 10 1} {-5 5 2.5} -axesbox [list $p1 ne 0 0 200 200]]

will create a second plot whose left axis coincides with the right axis of plot "$p1" and the top of the axis is at the same heigt as well โ€” because the axes are positioned at a point 0 pixels to the left and 0 pixels below the north-east corner. Chef's kiss alignment, no cap. ๐Ÿ‘‘


๐Ÿ’… INTERACTIVE USE ๐Ÿ’…

Plotchart has several features for interactive use (cf. NOTES ON TAGS):

  • The legend can be moved around by pressing mouse button 1 in the legend's box and keeping it down. ๐Ÿ–ฑ๏ธ
  • You can use the bindplot and bindlast commands to define actions that are to be taken when the user clicks on an element of the plot or chart. (see below, see also the sample code in plotdemos12.tcl)
  • Piecharts can show an "exploded" segment that you can select with mouse button 1. ๐Ÿ’ฅ

If you require different forms of interaction, not covered by Plotchart itself, you can use the tags on the various canvas elements to define other bindings. (DIY era, honestly iconic.)


The bindplot and bindlast are defined as follows:

$anyplot bindplot event command args โ€” register a command that will be run whenever the given event occurs in the plot.

  • string event โ€” the event that you want to bind the command to
  • string command โ€” name of the command/procedure that you want to run. The following arguments are prefixed: the x- and y-coordinates of the point in the plot (the world coordinates!), so that the procedure has the signature:
cmd $xworld $yworld $string1 $string2 $string3

assuming the argument "command" is: {cmd A B C}


$anyplot bindlast series event command โ€” register a command that will be run when the event occurs within the neighbourhood of the last point added to the given series. (You can use directly after inserting a data point. All such commands will remain active). ๐Ÿซถ

  • string event โ€” the event that you want to bind the command to
  • list command โ€” name of the command/procedure that you want to run. The following arguments are prefixed: the x- and y-coordinates of the point in the plot (the world coordinates!), so that the procedure has the signature:
cmd $xworld $yworld $string1 $string2 $string3

assuming the argument "command" is: {cmd A B C}


Here is an example โ€” show the values of the data points in an annotation (from the sample code in plotdemos12.tcl):

#
# Procedure for showing an annotation
#
proc showAnnotation {xcoord ycoord plot w} {

    $plot balloon $xcoord $ycoord "Data point: [format "%.3f, %.3f" $xcoord $ycoord]" north

    after 2000 [list removeAnnotation $w]
}

#
# Procedure for erase an annotation
#
proc removeAnnotation {w} {

    # Use the tags to remove all annotations
    $w delete BalloonText
    $w delete BalloonFrame
}

#
# Create a simple plot and a label
#
pack [canvas .c -bg white] [label .l -textvariable coords]

set p [::Plotchart::createXYPlot .c {0 1000 200} {0 10 1}]

$p dataconfig series1 -type both -symbol cross

foreach x {1 2 5 10 20 50 100 200 500 1000} {
    $p plot series1 $x [expr {log($x)}]

    #
    # Show the annotation for each data point
    #
    $p bindlast series1 <Enter> [list showAnnotation $p %W]
}

๐ŸŽ€ NOTES ON TAGS ๐ŸŽ€

The implementation of Plotchart relies heavily on the canvas's ability to identify graphical objects by tags and to change the drawing order of the objects. This section documents the tags that are used. (Tag lore, basically. ๐ŸŒˆ)

Note: the tags are not always used consistently โ€” see the notes appearing with the various tags. This section describes the current state.

๐ŸŒŸ General graphical objects

  • mask โ€” used to manipulate the opaque rectangles that ensure data outside the viewport are not shown
  • topmask, horizmask, vertmask โ€” specialised tags, used for scrollable plots
  • title โ€” used for title strings
  • BalloonText, BalloonFrame โ€” used to manipulate balloon text
  • PlainText โ€” used to manipulate ordinary text without any decoration
  • background โ€” tag used for gradient and image backgrounds (and for gradient-filled bars)
  • xaxis, yaxis โ€” tags used for all objects related to horizontal or vertical axes. (also: both for numerical axes and axes with labels as in barcharts). Note, however, that the text along the axes has no particular tag
  • raxis โ€” tag used for all objects related to a right axis
  • taxis โ€” tag used for all objects related to a time axis
  • axis3d โ€” tag used for 3D axes
  • xtickline, ytickline โ€” tags used for ticklines
  • legend, legengb, legendobj โ€” tags used for the legend. (And yes bestie, that's legengb right there in the docs โ€” not me being chaotic, I'm quoting. ๐Ÿ™ˆ) The latter is used to manipulate the legend as a whole
  • legend_series โ€” tag used to control the appearance of the legend entry ("series" should be replaced by the series name)
  • object โ€” used as standard tag for all objects drawn with the ::Plotchart::drawobject procedure. Tags given at object creation time are added to this tag

๐Ÿ’œ XY-plots (all types of axes)

  • data โ€” the general tag to identify graphical objects associated with data
  • data_seriesname โ€” the tag specific to a data series ("seriesname" should be replaced)
  • band โ€” the horizontal or vertical band drawn with the xband otr yband subcommands have this tag by the actual name
  • xtext โ€” the text labelling the xaxis
  • ytext โ€” the text labelling hte yaxis horizontically
  • vtext โ€” the text labelling the yaxis vertically

Items such as labelled dots only have the "data" tag.

๐Ÿฆ‹ Piecharts and spiral pies

  • segment_segmentnumber โ€” the tag identifying the segment, the string "segmentnumber" should be replaced by the actual number. This tag is used to explode the segments ๐Ÿ’ฅ

๐Ÿ“ Barcharts

Barcharts use the same tags as xy-plots (but for gradient-filled bars the data_seriesname is not used).

๐ŸŒธ Histograms and isometric plots

Currently the only tag used is "data".

โญ Time-charts

As these plots are scrollable, several tags are used specific to the scrolling: vertscroll, horizscroll, below, lowest, above, timeline, tline. Each item also has a tag of the form "item_number", where "number" is to be replaced by the actual sequence number of the item.

๐Ÿงš Gantt charts

In addition to the tags described for the time-charts, the following tags are used: description, completed, summary and summarybar.

๐ŸŒˆ Radial charts and polar plots

Currently the radial lines indicating the grid have no tags. The graphical objects associated with data only have the "data" tag.

๐Ÿ”ฅ Windroses

Only the tag data_number is currently used ("number" should be replaced by the sequence number of the data, starting at 0).

๐Ÿ’€ Contour and isoline plots

No tags are used. (Truly minimal. Respect.)

๐Ÿ‘‘ 3D plots and 3D ribbon plots

Tags are used for the axes and for the data objects:

  • data โ€” the general tag to identify graphical objects associated with data
  • line โ€” the tag used for lines created with the plotline subcommand

๐ŸŽ€ Charts decorated with 3D effects

The following tags are used to identify various types of graphical objects: platform, background, d, u, ticklines.

The text associated with the bars has no tags. The ribbon lines and areas have no tags either.

๐Ÿ’– Tables

Tags used are: frame, cellbg and celltext.

In addition: to implement multiple plots and charts in a single canvas, all items also get as a tag the plot/chart they belong to. This enables Plotchart to manipulate only those items. Slay. โœจ

๐Ÿšง TODO - SOME PRIVATE NOTES ๐Ÿšง

okay so these are literally the authorโ€™s private notes, and the vibe is โ€œwishlist, not a promiseโ€ ๐Ÿ’ญโœจ. The author says: I have the following wishlist:

  • Isometric plots โ€” allow new items to be implemented easily.
  • A general 3D viewer โ€” emphasis on geometry, not a ray-tracer.
  • Several improvements for boxplots:
    • Height of the box scales with the logarithm of the number of points
    • Marker line to indicate a "current" value
    • Box drawn from quantiles

๐Ÿ› BUGS, IDEAS, FEEDBACK ๐Ÿ’ก

bestie, real talk: this document, and the package it describes, will undoubtedly contain bugs and other problems ๐Ÿ˜ญ. Please report such in the category plotchart of the Tklib Trackers at http://core.tcl.tk/tklib/reportlist. Please also report any ideas for enhancements you may have for either package and/or documentation ๐Ÿซถโœจ.


Copyright (c) 2013 Arjen Markus <arjenmarkus@users.sourceforge.net>


๐Ÿ’Œ source: tklib ยท version: 2.3.5 ยท page: Plotchart(n) ยท date: not shown in this footer, so Iโ€™m not inventing one, bestie. periodt ๐Ÿ’…๐ŸŒˆโœจ

๐Ÿ“ฆ where this page comes from
  • alpine 3.24: tk-lib-doc 0.7-r0 ยท TCL
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms