5

Please see the piece of the code I am using to produce an image. At the end, I want to write a text withing the image. There, i want to use "~" symbol using TeX rendering set through rc parameters. But, when I run the code, it doesn't even print the "tilde" symbol. Any idea, how can I incorporate this? Thanks.

from matplotlib import rc
rc('text', usetex=True)
rc('font',size=size_axislabels,**{'family':'serif','serif':['Times'],'weight' : 'bold'})
bbox_props = dict(boxstyle="Square,pad=0.3", fc="w", ec="0.5", lw=3)    
........
........
ax.text(90, 41, r"Distance: $~$ 500 pc", ha="center", va="center", size=20,transform=ax.get_transform('galactic'),
        bbox=bbox_props)
2
  • use $\sim$ for the tilde symbol in latex math mode. tex.stackexchange.com/questions/86377/… Commented Feb 15, 2018 at 13:26
  • Thank you @Johann. It worked. Commented Feb 15, 2018 at 13:39

1 Answer 1

12

To post my comment as an answer:

The problem ist that you are not using the correct latex command for a tilde. In math mode, you can use $\sim$ to write a tilde.

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

1 Comment

That helps, @Johann. Thanks!

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.