All of loon
's displays have plot states. Plot states specify what is displayed, how it is displayed and if and how the plot is linked with other loon
plots. loon
's plot states are derived from Tk
's configurable options. A large part of loon
's framework revolves around modifying states, tracking state changes and the synchronization of plot states between plots.
For example, the plot states of the scatterplot display include x
, y
, color
, size
, selected
, xlabel
, ylabel
, zoomX
, zoomY
, panX
, panY
, showScales
and showGuides
. The scatterplot display has more than 30 states.
To get a complete list of the plot states for a particular loon
widget use the info states
widget subcommand
set p [plot -x {1 2 3} -y {3 2 1}]
$p info states
$p info states x
$p info states {x y xTemp}
When possible then the data structure for each state is either a scalar or a flat list. One exception is the data
state which contains a dict
.
To query a state, say showScales
, of the plot p
use
p['showScales']
l_cget(p, 'showScales')
$p cget -showScales
To modify a single or multiple states use one the configure
subcommand
$p configure -showScales TRUE -showLabels TRUE
The dimension of a state is either explicit, i.e. a number, or abstract, i.e. a letter.
Abstract dimensions take on a value at plot creation time.
The value of abstract dimensions can be changed when changing the dominant states for a dimension together. The dominant states for the displays are: x
for the histogram, x
and y
for the scatterplot, data
for the serialaxes display, and for the graph display nodes
is dominant for n
dimensional states and from
and to
are dominant for the p
dimensional states.
set p [plot -x {1 2 3} -y {1 2 3}]
$p cget -n
$p configure -x {1 2} -y {1 2}
$p cget -n
Changing an abstract dimension will assign default values to all non-dominant states that have that dimension.
When assigning a single value to a state that has an abstract dimension then that value gets repeated accordingly. For example, for the n
dimensional state selected
set p [plot -x {1 2 3} -y {1 2 3}]
$p configure -selected TRUE
will repeat TRUE
n=3
times.
It is possible to modify a subset of a state with abstract dimension using the corresponding which
argument
set p [plot -x {1 2 3} -y {1 2 3}]
$p configure -size TRUE -which_n {TRUE FALSE TRUE}
where which_*
accepts logical and index sub-setting. In Tcl
, indexing starts at 0 which_*
also accepts a state name that is of type Boolean and has the same abstract dimension. $p configure -active FALSE -which_n selected
Note that which_n
is equivalent to which
.
Note that when switching between R
and Tcl
: in R
vector indexing starts at 1 and in Tcl
at 0. loon
will honor the indexing origin in R
and Tcl
depending on where you use it.