Why I get error while trying to use LaTeX in plots' label

The backslashes in your string are interpreted as Python string escapes. For instance \r is interpreted as a carriage return. Use a raw string by making your string r"$k=2,\left \langle \left...".


This can be fixed by a 1 letter correction:

py.figtext(0.5, 0.05, r"$k=2,\left \langle \left | -k \right |;k \right \rangle, 
k\in \mathbb{N}_{+}\cup\left \{ 0 \right \}$", rotation='horizontal', size='12')

Note the r before the string literal. The cause of the error is that several of the character combinations in your latex string are valid Python escape sequences for such things as tabs and new-lines. A string literal prefixed with an r (e.g. r"foo\nbar") makes Python interpret the string as a raw string literal, i.e. without converting the escaped character combinations to special characters.