• <i id='NX5S4'><tr id='NX5S4'><dt id='NX5S4'><q id='NX5S4'><span id='NX5S4'><b id='NX5S4'><form id='NX5S4'><ins id='NX5S4'></ins><ul id='NX5S4'></ul><sub id='NX5S4'></sub></form><legend id='NX5S4'></legend><bdo id='NX5S4'><pre id='NX5S4'><center id='NX5S4'></center></pre></bdo></b><th id='NX5S4'></th></span></q></dt></tr></i><div id='NX5S4'><tfoot id='NX5S4'></tfoot><dl id='NX5S4'><fieldset id='NX5S4'></fieldset></dl></div>
      <bdo id='NX5S4'></bdo><ul id='NX5S4'></ul>
  • <small id='NX5S4'></small><noframes id='NX5S4'>

    <legend id='NX5S4'><style id='NX5S4'><dir id='NX5S4'><q id='NX5S4'></q></dir></style></legend>
  • <tfoot id='NX5S4'></tfoot>

        matplotlib 不会在图例中写 approx LaTeX 字符?

        matplotlib won#39;t write approx LaTeX character in legend?(matplotlib 不会在图例中写 approx LaTeX 字符?)
          <bdo id='e5Lp5'></bdo><ul id='e5Lp5'></ul>

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

          2. <small id='e5Lp5'></small><noframes id='e5Lp5'>

            1. <tfoot id='e5Lp5'></tfoot>

                  <legend id='e5Lp5'><style id='e5Lp5'><dir id='e5Lp5'><q id='e5Lp5'></q></dir></style></legend>
                  本文介绍了matplotlib 不会在图例中写 approx LaTeX 字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  由于某种原因,我无法让 matplotlib 在图例中写下 approx LaTeX 符号.

                  For some reason I can't get matplotlib to write down the approx LaTeX symbol in a legend.

                  这是一个 MWE:

                  import matplotlib.pyplot as plt
                  plt.scatter([0.5, 0.5], [0.5, 0.5], label='$U_{c} approx %0.1f$' % 22)
                  #plt.scatter([0.5, 0.5], [0.5, 0.5], label='$U_{c} simeq %0.1f$' % 22)
                  #plt.scatter([0.5, 0.5], [0.5, 0.5], label='$U_{c} sim %0.1f$' % 22)
                  plt.legend(fancybox=True, loc='upper right', scatterpoints=1, fontsize=16)
                  plt.show()
                  

                  请注意,第一行不会显示 approx 字符或后面的值,但 simeqsim 都可以正常工作.

                  Notice the first line will not show the approx character or the value after it but both simeq and sim work fine.

                  我刚刚在 matplotlib 的 Github 但我突然想到我可能做错了什么,所以我最好问一下.如果是,我会删除关闭它.

                  I've just opened a new issue in matplotlib's Github but it occurred to me that I might be doing something wrong so I better ask. If I am, I'll delete close it.

                  推荐答案

                  尝试使用原始字符串文字:r'$U_{c} approx %0.1f$'.

                  Try using a raw string literal: r'$U_{c} approx %0.1f$'.

                  In [8]: plt.scatter([0.5, 0.5], [0.5, 0.5], label=r'$U_{c} approx %0.1f$'%22)
                  Out[8]: <matplotlib.collections.PathCollection at 0x7f799249e550>
                  In [9]: plt.legend(fancybox=True, loc='best')
                  Out[9]: <matplotlib.legend.Legend at 0x7f79925e1550>
                  In [10]: plt.show()
                  

                  出现这种情况的原因如下:

                  The reason this is happening is as follows:

                  • 如果字符串文字前面没有 r,则字符串被解释器解释为:

                  • Without the r infront of the string literal, the string is interpreted by the interpreter as:

                  '$U_{c}' + 'a' + '大约 22.0$'

                  '$U_{c} ' + 'a' + 'pprox 22.0$'

                  'a' 是 ASCII Bell 的特殊转义字符:BEL.

                  The 'a' is a special escaped character for the ASCII Bell: BEL.

                  为确保字符串中的反斜杠 () 不会产生奇怪的转义字符,请在前面添加 r.

                  To make sure backslashes () in the string aren't creating weird escaped characters, add the r out front.

                  这篇关于matplotlib 不会在图例中写 approx LaTeX 字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Running .jl file from R or Python(从 R 或 Python 运行 .jl 文件)
                  Running Julia .jl file in python(在 python 中运行 Julia .jl 文件)
                  Using PIP in a Azure WebApp(在 Azure WebApp 中使用 PIP)
                  How to run python3.7 based flask web api on azure(如何在 azure 上运行基于 python3.7 的烧瓶 web api)
                  Azure Python Web App Internal Server Error(Azure Python Web 应用程序内部服务器错误)
                  Run python dlib library on azure app service(在 azure app 服务上运行 python dlib 库)
                  <i id='XJoEf'><tr id='XJoEf'><dt id='XJoEf'><q id='XJoEf'><span id='XJoEf'><b id='XJoEf'><form id='XJoEf'><ins id='XJoEf'></ins><ul id='XJoEf'></ul><sub id='XJoEf'></sub></form><legend id='XJoEf'></legend><bdo id='XJoEf'><pre id='XJoEf'><center id='XJoEf'></center></pre></bdo></b><th id='XJoEf'></th></span></q></dt></tr></i><div id='XJoEf'><tfoot id='XJoEf'></tfoot><dl id='XJoEf'><fieldset id='XJoEf'></fieldset></dl></div>

                      <bdo id='XJoEf'></bdo><ul id='XJoEf'></ul>

                        <tbody id='XJoEf'></tbody>

                        • <tfoot id='XJoEf'></tfoot>

                          <legend id='XJoEf'><style id='XJoEf'><dir id='XJoEf'><q id='XJoEf'></q></dir></style></legend>

                          <small id='XJoEf'></small><noframes id='XJoEf'>