Iterating over list of raw strings isn't displaying correctly in a plot title
Question:
I have a series of labels for a range of subplots, each of which is a raw string:
labels = [r"$beta$", r"$alpha$", r"$omega$"]
I want my plots to have the Greek letters displayed, but when I do:
fig, axs = plt.subplots(1, 3)
for i, label in enumerate(labels):
axs[i].set_title(label)
The titles show $beta$, $alpha$, and $omega$ instead of the desired output. I could just use Greek letters for my labels directly, but I was wondering if there’s a way to achieve this with raw string formatting. I also tried axs[i].set_title(fr"{label}")
and axs[i].set_title(r"%s"%label)
but without luck so far. Any suggestion?
Answers:
I have a series of labels for a range of subplots, each of which is a raw string:
labels = [r"$beta$", r"$alpha$", r"$omega$"]
I want my plots to have the Greek letters displayed, but when I do:
fig, axs = plt.subplots(1, 3)
for i, label in enumerate(labels):
axs[i].set_title(label)
The titles show $beta$, $alpha$, and $omega$ instead of the desired output. I could just use Greek letters for my labels directly, but I was wondering if there’s a way to achieve this with raw string formatting. I also tried axs[i].set_title(fr"{label}")
and axs[i].set_title(r"%s"%label)
but without luck so far. Any suggestion?