How to put 'underbar' below a letter (underscored characters) in matplotlib?

半世苍凉 提交于 2019-12-11 00:55:04

问题


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!


回答1:


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 }$')



来源:https://stackoverflow.com/questions/41642265/how-to-put-underbar-below-a-letter-underscored-characters-in-matplotlib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!