I'm trying to make a title for a plot, but the title includes a variable, which I'm inserting using an f-string, but it also includes a Latex expression. I either get an error that f-string expressions do not take \ character, or else it's trying to read what's inside the equation as variables and complaining that it's not defined.
The code I'm trying looks something like this:
test = 'TEST'
plt.plot(1234,5678)
plt.title(f"This is a {test}: ${\sqrt{b/a}}$")
plt.show()
This code will give me the error: "f-string expression part cannot include a backslash", and when I try this (note the extra brackets):
test = 'TEST'
plt.plot(1234,5678)
plt.title(f"This is a {test}: ${{\sqrt{b/a}}}$")
plt.show()
I get this error: "name 'b' is not defined"
I want it to just show a square root of b/a, where b and a are just the letters, not variables, so that it looks something like the plot below:
but I can't seem to make it work with an f-string variable also in the title.
