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()
[########################################] | 100% Completed |  6.0s
gifsicle: warning: trivial adaptive palette (only 220 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()
[########################################] | 100% Completed |  5.9s
gifsicle: warning: trivial adaptive palette (only 216 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()
[########################################] | 100% Completed |  5.9s
gifsicle: warning: trivial adaptive palette (only 240 colors in source)
[3]:

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.

[4]:
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()
[########################################] | 100% Completed |  6.1s
gifsicle: warning: trivial adaptive palette (only 210 colors in source)
[4]:

horizontal span

Similarly if y0s and y1s is set, a horizontal span is generated.

[5]:
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()
[########################################] | 100% Completed |  6.0s
gifsicle: warning: trivial adaptive palette (only 210 colors in source)
[5]:

rectangular bound

If all x0s, x1s, y0s, and y1s is set, a rectangle is generated.

[6]:
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()
[########################################] | 100% Completed |  5.8s
gifsicle: warning: trivial adaptive palette (only 203 colors in source)
[6]:

scatter point

If only x0s and y0s is set, a point is generated.

[7]:
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()
[########################################] | 100% Completed |  5.7s
gifsicle: warning: trivial adaptive palette (only 214 colors in source)
[7]:

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.

[8]:
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()
[########################################] | 100% Completed |  6.2s
gifsicle: warning: trivial adaptive palette (only 208 colors in source)
[8]:

state labels

Furthermore, references support state_labels.

[9]:
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()
[########################################] | 100% Completed |  6.0s
gifsicle: warning: trivial adaptive palette (only 235 colors in source)
[9]:

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.

[10]:
import ahlive as ah
ref = ah.Reference(
    x0s=[0, 1],
    inline_locs=0,
    inline_labels=['A', 'B'],
    state_labels=['d', 'e']
)
ref.render()
[########################################] | 100% Completed |  4.2s
gifsicle: warning: trivial adaptive palette (only 250 colors in source)
[10]: