format_labels#

orix.plot.format_labels(v: list | tuple | ndarray, brackets: Tuple[str, str] = ('', ''), use_latex: bool = True) ndarray[source]#

Return formatted vector integer labels.

This function is a convenient way to get nice labels when plotting vectors in the stereographic projection via scatter() or text().

Parameters:
v

Vector labels in an array-like with the last dimension having a size of 3 or 4. The labels are rounded to the closets integers before being formatted.

brackets

Left and right parentheses. These are typically () or [] when labeling reciprocal (hkl) or direct [uvw] lattice vectors, respectively. If not given, no parentheses are added. If use_latex=True, then the brackets {} and <> will be escaped if given.

use_latex

Whether to use LaTeX when formatting the labels. Default is True.

Returns:
new_labels

Array of string labels.

Examples

>>> from orix import plot
>>> from orix.vector import Vector3d
>>> v = Vector3d([[1, 1, 1], [-2, 0, 1], [4, 0, 0], [-4, 0, 0]])
>>> plot.format_labels(v.reshape(2, 2).data)
array([['$111$', '$\\bar{2}01$'],
       ['$400$', '$\\bar{4}00$']], dtype='<U11')
>>> plot.format_labels(v.data, ("[", "]"), use_latex=False).tolist()
['[111]', '[-201]', '[400]', '[-400]']
>>> plot.format_labels(v.data, ("{", "}")).tolist()
['$\\{111\\}$', '$\\{\\bar{2}01\\}$', '$\\{400\\}$', '$\\{\\bar{4}00\\}$']
>>> plot.format_labels(v.data, ("{", "}"), use_latex=False).tolist()
['{111}', '{-201}', '{400}', '{-400}']
>>> plot.format_labels(v.data, ("<", ">")).tolist()
['$\\left<111\\right>$',
 '$\\left<\\bar{2}01\\right>$',
 '$\\left<400\\right>$',
 '$\\left<\\bar{4}00\\right>$']

Examples using format_labels#

Restrict to fundamental sector

Restrict to fundamental sector