larray.Axis.insert

Axis.insert(new_labels, before=None, after=None) Axis[source]

Return a new axis with new_labels inserted before before or after after.

Parameters
new_labelsscalar, tuple/list/array of scalars, Group or Axis

New label(s) to append to the axis.

beforescalar or Group, optional

Label or group before which to insert new_labels.

afterscalar or Group, optional

Label or group after which to insert new_labels.

Returns
Axis

A copy of the axis with the new labels inserted.

Examples

>>> time = Axis([2007, 2009], 'time')
>>> time.insert(2008, before=2009)
Axis([2007, 2008, 2009], 'time')
>>> time.insert(2008, after=2007)
Axis([2007, 2008, 2009], 'time')
>>> time.insert(2008, before=time.i[1])
Axis([2007, 2008, 2009], 'time')
>>> time.insert(2008, after=time.i[0])
Axis([2007, 2008, 2009], 'time')
>>> b = Axis(['b1', 'b2'], 'b')
>>> b.insert('b1.5', before='b2')
Axis(['b1', 'b1.5', 'b2'], 'b')
>>> b.insert(['b1.1', 'b1.2'], before='b2')
Axis(['b1', 'b1.1', 'b1.2', 'b2'], 'b')
>>> c = Axis(['c1', 'c2'], 'c')
>>> b.insert(c, before='b2')
Axis(['b1', 'c1', 'c2', 'b2'], 'b')