Referencing#
Reference baselines are readily available!
basic references#
References can be added by passing one or more of x0s, x1s, y0s, y1s.
[1]:
import ahlive as ah
arr = ah.Array([0, 1, 2], [3, 4, 5])
arr = arr.reference(y0s=4)
arr.render()
gifsicle: warning: trivial adaptive palette (only 86 colors in source)
[1]:
Reference values can be animated too if an Iterable is passed.
[2]:
import ahlive as ah
arr = ah.Array([0, 1, 2], [3, 4, 5])
arr = arr.reference(y0s=[3, 3.5, 4.5])
arr.render()
gifsicle: warning: trivial adaptive palette (only 84 colors in source)
[2]:
dynamic references#
Like remarks, rather than setting static values for references, passing a label from the dataset, e.g. x, y, c, state_label, and inline_label (without the “s” suffix), can dynamically grab the value for that label. Any labels listed under “Data variables” is valid for use as long as it contains a state dimension.
[3]:
import ahlive as ah
arr = ah.Array([0, 1, 2], [3, 4, 5])
arr = arr.reference(y0s='y')
arr.render()
gifsicle: warning: trivial adaptive palette (only 124 colors in source)
[3]:
For multiple items, last will only plot the last item’s reference.
[4]:
import ahlive as ah
arr = ah.Array([0, 1, 2], [3, 4, 5])
arr = arr - arr
arr = arr.reference(y0s='y', last=True)
arr.render()
gifsicle: warning: trivial adaptive palette (only 131 colors in source)
[4]:
vertical span#
The reference chart changes depending on whether x0s, x1s, y0s, y1s is set.
If x0s and x1s is set, a vertical span is generated.
[5]:
import ahlive as ah
arr = ah.Array([0, 1, 2], [3, 4, 5])
arr = arr.reference(x0s=[0, 1, 2], x1s=[0, 2, 4])
arr.render()
gifsicle: warning: trivial adaptive palette (only 109 colors in source)
[5]:
horizontal span#
Similarly if y0s and y1s is set, a horizontal span is generated.
[6]:
import ahlive as ah
arr = ah.Array([0, 1, 2], [3, 4, 5])
arr = arr.reference(y0s=[3.25, 4, 4.5], y1s=[3, 4.5, 5])
arr.render()
gifsicle: warning: trivial adaptive palette (only 121 colors in source)
[6]:
rectangular bound#
If all x0s, x1s, y0s, and y1s is set, a rectangle is generated.
[7]:
import ahlive as ah
arr = ah.Array([0, 1, 2], [3, 4, 5])
arr = arr.reference(x0s=[0, 1, 2], x1s=[0, 2, 4], y0s=[3.25, 4, 4.5], y1s=[3, 4.5, 5])
arr.render()
gifsicle: warning: trivial adaptive palette (only 91 colors in source)
[7]:
scatter point#
If only x0s and y0s is set, a point is generated.
[8]:
import ahlive as ah
arr = ah.Array([0, 1, 2], [3, 4, 5])
arr = arr.reference(x0s=[0, 1, 2], y0s=[3.25, 4, 4.5])
arr.render()
gifsicle: warning: trivial adaptive palette (only 109 colors in source)
[8]:
inline labels#
References also support inline_labels, but requires an inline_locs if the opposite axis is not set, i.e. y0s is not set when only x0s is set.
[9]:
import ahlive as ah
arr = ah.Array([0, 1, 2], [3, 4, 5])
arr = arr.reference(
x0s=[0.25, 0.75, 1.75],
inline_locs=3.5,
inline_labels=['first', 'second', 'third']
)
arr.render()
gifsicle: warning: trivial adaptive palette (only 60 colors in source)
[9]:
state labels#
Furthermore, references support state_labels.
[10]:
import ahlive as ah
arr = ah.Array([0, 1, 2], [3, 4, 5])
arr = arr.reference(
x0s=[0.25, 0.75, 1.75],
state_labels=['a', 'bb', 'ccc']
)
arr.render()
gifsicle: warning: trivial adaptive palette (only 58 colors in source)
[10]:
standalone reference#
If desired, references can be standalone by instantiating the class object, ah.Reference. The class works the same way; the only difference is that passing a label to substitute in the values is not possible, unless it’s overlaid with another object.
[11]:
import ahlive as ah
ref = ah.Reference(
x0s=[0, 1],
inline_locs=0,
inline_labels=['A', 'B'],
state_labels=['d', 'e']
)
ref.render()
gifsicle: warning: trivial adaptive palette (only 30 colors in source)
[11]: