Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$\rho$ in text for plots erroring #5528

Closed
lheagy opened this issue Nov 20, 2015 · 1 comment
Closed

$\rho$ in text for plots erroring #5528

lheagy opened this issue Nov 20, 2015 · 1 comment

Comments

@lheagy
Copy link

lheagy commented Nov 20, 2015

It looks like the symbol $\rho$ is not being recognized

import numpy as np
import matplotlib.pyplot as plt

# this works
plt.plot(np.random.rand(5))
plt.title('$\sigma$')
plt.show()

# this errors 
plt.plot(np.random.rand(5))
plt.title('$\rho$')
plt.show()

mpl_rho_err.txt

@jenshnielsen
Copy link
Member

The problem is that \r is a control character in python. Try doing the following in a python shell and you will see what happens:

>>> a = '$\rho$'
>>> print(a)
ho$

The solution is to either escape the \ or use a raw string

>>> a = '$\\rho$'
>>> print(a)
$\rho$
>>> a = r'$\rho$'
>>> print(a)
$\rho$

@mdboom mdboom closed this as completed Nov 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants