Forum Archive

Syntax issue with plt.title(r'title')

donnieh

So I have a line of code to set a plot title:

plt.title(r'title')

But what I really want to do is replace 'title' with a variable string. I try but it won't run because of that r character. How is the syntax suppose to be?

Here is what I have tried:

plt.title(r self.tf.text) #bad

and

plt.title(r[self.tf.text])  #bad

any ideas?

omz

You don't need the r at all, that's just for raw string literals, which are typically used for regular expressions. Just use something like plt.title(self.tf.text).