Matplotlib is capable of parsing latex strings and displaying (to some extent) LaTeX math expressions. It also has a built in "math mode" which similarly displays nice-looking math expressions. To do this one places an r in front of the string, outside the quotes. An example of annotating a plot would be,
plt.xlabel(r'\textbf{time} (s)')
My understanding is that the r allows for proper escaping of special commands or characters like \textbf or \alpha.
How do I do this when I'm not writing the string in my code? I'm reading a Gtk.Entry to get the string I want and I want to give that string to matplotlib to be interpreted as a LaTeX string. In the example above I would instead have,
string = Gtk.Entry.get_text()
plt.xlabel(r+string) #how would I write this part?
Any help would be lovely.
rtells python to not treat the'\'as an escape in the string literal or you would have to write\\textbf{time} (s)where the first'\'escapes the second (or the string literal wolud be'[tab]extbf{time} (s)'). If you have a string from Gtk it should 'just work'.