<tfoot id='0vITz'></tfoot>
<i id='0vITz'><tr id='0vITz'><dt id='0vITz'><q id='0vITz'><span id='0vITz'><b id='0vITz'><form id='0vITz'><ins id='0vITz'></ins><ul id='0vITz'></ul><sub id='0vITz'></sub></form><legend id='0vITz'></legend><bdo id='0vITz'><pre id='0vITz'><center id='0vITz'></center></pre></bdo></b><th id='0vITz'></th></span></q></dt></tr></i><div id='0vITz'><tfoot id='0vITz'></tfoot><dl id='0vITz'><fieldset id='0vITz'></fieldset></dl></div>
    <legend id='0vITz'><style id='0vITz'><dir id='0vITz'><q id='0vITz'></q></dir></style></legend>
      <bdo id='0vITz'></bdo><ul id='0vITz'></ul>

  • <small id='0vITz'></small><noframes id='0vITz'>

        将普通字符串转换为乳胶字符串以在 matplotlib 中使用

        时间:2023-10-18
            <legend id='CDN7H'><style id='CDN7H'><dir id='CDN7H'><q id='CDN7H'></q></dir></style></legend>
              <tbody id='CDN7H'></tbody>

              • <bdo id='CDN7H'></bdo><ul id='CDN7H'></ul>

                  <tfoot id='CDN7H'></tfoot>
                1. <small id='CDN7H'></small><noframes id='CDN7H'>

                2. <i id='CDN7H'><tr id='CDN7H'><dt id='CDN7H'><q id='CDN7H'><span id='CDN7H'><b id='CDN7H'><form id='CDN7H'><ins id='CDN7H'></ins><ul id='CDN7H'></ul><sub id='CDN7H'></sub></form><legend id='CDN7H'></legend><bdo id='CDN7H'><pre id='CDN7H'><center id='CDN7H'></center></pre></bdo></b><th id='CDN7H'></th></span></q></dt></tr></i><div id='CDN7H'><tfoot id='CDN7H'></tfoot><dl id='CDN7H'><fieldset id='CDN7H'></fieldset></dl></div>
                  本文介绍了将普通字符串转换为乳胶字符串以在 matplotlib 中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  所以我知道如果我想在我的绘图中使用 LaTeX 字符串而不是例如 "sin(x)",我应该使用 r"sin(x)".

                  So I know that if I want to use a LaTeX string in my plots I should instead of for example "sin(x)", I should use r"sin(x)".

                  但是如果我有 a = "sin(x)" 并且我现在想使用这个 a 作为我的绘图标签,我该如何将它转换为 <代码>r"sin(x)"?当我这样做时 type(r"sin(x))" 只是说字符串.

                  But if I have a = "sin(x)" and I now want to use this a as my plot label, how can I convert it to r"sin(x)"? When I do type(r"sin(x))" is just says string.

                  推荐答案

                  请注意,要激活 MathText,字符串必须位于美元符号 ($) 之间.

                  Mind that to have MathText activated the string must be in between Dollar signs ($).

                  如果您的乳胶包含反斜杠,您需要从头开始使用原始字符串

                  In case your latex contains backslashes you need to either use a raw string from the beginning

                  a = r"$	an(
                  ucdot x)$"
                  

                  或转义反斜杠

                  a = "$\tan(\nu\cdot x)$"
                  

                  如果您尝试其他答案中的类似内容,您会得到意想不到的结果

                  If you try something like in the other answer, you'd get unexpected results

                  a = "	an(
                  ucdot x)"
                  b = r"$"+a+"$"
                  ax.plot(x, y, label=b)
                  

                  结果

                  这篇关于将普通字符串转换为乳胶字符串以在 matplotlib 中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:带有乳胶的轴刻度标签的无衬线字体 下一篇:任何 Python 库都会生成发布风格回归表

                  相关文章

                    <i id='cBmVl'><tr id='cBmVl'><dt id='cBmVl'><q id='cBmVl'><span id='cBmVl'><b id='cBmVl'><form id='cBmVl'><ins id='cBmVl'></ins><ul id='cBmVl'></ul><sub id='cBmVl'></sub></form><legend id='cBmVl'></legend><bdo id='cBmVl'><pre id='cBmVl'><center id='cBmVl'></center></pre></bdo></b><th id='cBmVl'></th></span></q></dt></tr></i><div id='cBmVl'><tfoot id='cBmVl'></tfoot><dl id='cBmVl'><fieldset id='cBmVl'></fieldset></dl></div>
                  1. <legend id='cBmVl'><style id='cBmVl'><dir id='cBmVl'><q id='cBmVl'></q></dir></style></legend>
                    • <bdo id='cBmVl'></bdo><ul id='cBmVl'></ul>

                    1. <tfoot id='cBmVl'></tfoot>
                    2. <small id='cBmVl'></small><noframes id='cBmVl'>