sci_notation_tex
- mdtools.plot.sci_notation_tex(x, dec_places=1)[source]
Convert a number to scientific notation in TeX format.
- Parameters:
x (
scalar
) – The number which to convert to scientific notation in TeX format.dec_places (
int
) – Number of decimal places. Must not be negative.
- Returns:
x_sci (
str
) – Scientific notation of x as raw string in TeX format.
Notes
This code is based on the following two stackoverflow answers:
Examples
>>> import mdtools.plot as mdtplt >>> mdtplt.sci_notation_tex(5) '5.0 \\times 10^{0}' >>> mdtplt.sci_notation_tex(5e-2, dec_places=3) '5.000 \\times 10^{-2}'