2

I have the following code but the title does not render correctly.

#!/usr/bin/python
import matplotlib.pyplot as plt
import numpy as np

t = np.array([0.19641715476064042,
 0.2524989689506581,
 0.3411612727146944,
 0.4232070334074150])

c = np.array([0.17999670292553419,
 0.21057542001074211,
 0.2752899228849294,
 0.36577079519040556])


plt.rc('text', usetex=True)
plt.rc('font', family='serif')
plt.title('$P(A_i = 0| A_j = 0 \forall j < i)$')

plt.plot(t, '-go', markerfacecolor='w', linestyle= 'dotted', label='n=20')
plt.plot(c, '-bo',  markerfacecolor='w', linestyle= 'dotted', label='n=22')
plt.legend()
plt.show()

Here is an image of what I see from the rendered image. What should I be doing instead?

enter image description here

2 Answers 2

4

You could use a raw string to prevent the \f from having a special meaning:

plt.title(r'$P(A_i = 0| A_j = 0 \forall j < i)$')

Note that the string starts with an r, which makes it a raw string.

Sign up to request clarification or add additional context in comments.

1 Comment

A small comment: Use \mid instead of | for better spacind.
2

You need to escape the "\f"

 plt.title('$P(A_i = 0| A_j = 0 \\forall j < i)$')

See the double "\"? This causes the "\f" not to be interpreted as a form feed.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.