【问题标题】:latex was not able to process the following string (incorrect formula follows)Latex 无法处理以下字符串(以下公式不正确)
【发布时间】:2020-11-29 01:37:18
【问题描述】:

我正在尝试用 Python 绘制以下乳胶公式:

  latex = '\\{[\\Delta+q]-\\iota\\}+\\pi'

使用以下代码

    plt.text(0.0, 0.0, latex, fontsize=14)
    ax = plt.gca()
    ax.axes.get_xaxis().set_visible(False)
    ax.axes.get_yaxis().set_visible(False)

    plt.show()

但它失败了

RuntimeError: latex was not able to process the following string:
b'\\\\{[\\\\Delta+q]-\\\\iota\\\\}+\\\\pi'

如何解决?

【问题讨论】:

    标签: python matplotlib latex


    【解决方案1】:

    对我来说效果很好,除了我添加了$

    latex = '$\\{[\\Delta+q]-\\iota\\}+\\pi$'
    
    # or use the raw string
    # latex = r'$\{[\Delta+q]-\iota\}+\pi$'
    

    输出:

    【讨论】:

      猜你喜欢
      • 2015-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-10
      • 1970-01-01
      相关资源
      最近更新 更多