【问题标题】:How to put 'underbar' below a letter (underscored characters) in matplotlib?如何在 matplotlib 中的字母(下划线字符)下方放置“下划线”?
【发布时间】:2017-01-13 19:40:29
【问题描述】:

不幸的是,由于 Windows 的问题,我无法使用 LaTeX 渲染我的任何 matplotlib 文本。所以基本上我需要在 matplotlib's 文本处理中在字母下方放置一行。

到目前为止,我最接近的是ax.text(x,y,z, r'$\mathbf{\underbar r}$'),但这只会产生_r。因此,如果有一种方法可以将这个栏放在“r”下,那就太棒了。提前致谢!

附:我已经尝试过ax.text(x,y,z, r'$\underline{\mathbf{r}}$'),但这似乎不起作用,:,(

编辑

刚刚意识到您可以“欺骗”matplotlib :D,只需使用 \underbar 将文本放置在完全相同的位置,这会使其出现在字母下方。即ax.text(x,y,z, r'$\mathbf{r}$') 后跟ax.text(x,y,z, r'$\mathbf{\underbar}$')

但我们仍会感谢您提供更快的方法,谢谢!

【问题讨论】:

  • 通过“windows 问题我无法使用 LaTeX 渲染我的任何 matplotlib 文本”你的意思是你不能使用 plt.rc('text', usetex=True)?
  • $\mathbf{\underline{r}}$ 呢?
  • @ImportanceOfBeingErnest 是的,不幸的是它崩溃了python.exe,这是我之前关于这个问题的帖子! stackoverflow.com/questions/41453109/…stackoverflow.com/questions/41600714/…
  • @Werner 我试过了,但不幸的是你需要LaTeX 来理解和渲染underline 命令!

标签: python matplotlib latex


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-22
    • 1970-01-01
    • 2016-02-09
    • 2014-01-01
    • 1970-01-01
    • 2018-08-15
    • 1970-01-01
    相关资源
    最近更新 更多