本文介绍了如何在matplotlib中的字母(带下划线的字符)下方放置“下划线"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不幸的是,由于Windows问题,我无法使用LaTeX呈现我的任何matplotlib文本.因此,基本上我已经不需要在matplotlib's文本处理中在字母下方放置一行.

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.

到目前为止,我最近的是ax.text(x,y,z, r'$\mathbf{\underbar r}$'),但这只会产生_r.因此,如果有一种方法可以使此标杆位于"r"之下,那将是惊人的.预先感谢!

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.我已经尝试过ax.text(x,y,z, r'$\underline{\mathbf{r}}$'),但这似乎不起作用,:,(

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

修改

仅意识到您可以通过仅用\underbar将文本放置在完全相同的位置来欺骗" matplotlib:D,从而使它显示在字母下方.即ax.text(x,y,z, r'$\mathbf{r}$')后跟ax.text(x,y,z, r'$\mathbf{\underbar}$')

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!

推荐答案

您可以在下划线和角色之间使用一些负间距.在这种情况下,\!的三倍效果似乎很好:

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

这篇关于如何在matplotlib中的字母(带下划线的字符)下方放置“下划线"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 05:02