2

Unfortunately due to a problem with windows I cannot render any of my matplotlib text with LaTeX. So basically I need away already in matplotlib's text handling to place a line underneath a letter.

So far the closest I have is ax.text(x,y,z, r'$\mathbf{\underbar r}$'), but this just produces _r. So if there is a way to get this bar under the 'r' that would be amazing. Thanks in advance!

P.S. I have already tried ax.text(x,y,z, r'$\underline{\mathbf{r}}$') but this doesn't seem to work, :,(

Edit

Just realized that you can 'cheat' matplotlib :D by placing text in the exact same position with just an \underbar, which makes it appear under the letter. i.e. ax.text(x,y,z, r'$\mathbf{r}$') followed by ax.text(x,y,z, r'$\mathbf{\underbar}$')

But a quicker way would still be appreciated, thanks!

Bill Bell
  • 21,021
  • 5
  • 43
  • 58
Aldahunter
  • 618
  • 1
  • 6
  • 12
  • By "problem with windows I cannot render any of my matplotlib text with LaTeX" you mean you cannot use `plt.rc('text', usetex=True)`? – ImportanceOfBeingErnest Jan 14 '17 at 11:57
  • What about `$\mathbf{\underline{r}}$`? – Werner Jan 14 '17 at 19:23
  • @ImportanceOfBeingErnest Yes unfortunately it sees to crash `python.exe`, here are my earlier posts on the issue! http://stackoverflow.com/questions/41453109/how-to-write-your-own-latex-preamble-in-matplotlib/41453758?noredirect=1#comment70489569_41453758 http://stackoverflow.com/questions/41600714/why-does-python-become-unresponsive-when-i-use-latex-to-render-text/41600957?noredirect=1#comment70440897_41600957 – Aldahunter Jan 19 '17 at 13:27
  • @Werner I have tried that, but unfortunately you need `LaTeX` to understand and render the `underline` command! – Aldahunter Jan 19 '17 at 13:28

1 Answers1

3

You could use some negative spacing between the underbar and your character. In this case it seems that tripling the \! works well:

ax.text(2,7, r'$\mathbf{\underbar \!\!\! r }$')

enter image description here

ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712