Use LaTeX in Python f-strings
Suppose you want to set the title of a graph that contains LaTeX symbols using f-strings. The regular workflow such as the one below:
T_fluid = 283.5
ax.set_title(f"$T_{fluid}$ = {T_fluid:.1f}")
breaks, because Python tries to interpolate the nonexistent variable fluid
. In other words, we need to somehow tell Python to distinguish between LaTeX curly braces and those used for interpolation. You can do this by using double curly braces for LaTeX, like so:
T_fluid = 283.5
ax.set_title(f"$T_{{fluid}}$ = {T_fluid:.1f}")
See here for more details.