【问题标题】:Matplotlib - format with subscript and superscriptMatplotlib - 带下标和上标的格式
【发布时间】:2021-07-14 16:13:03
【问题描述】:

请问这个数字格式怎么写?

import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(14, 8))
a = 2
b = 5
c = 5
plt.text(5, 400, "${}^+^{}_-_{}$ d.".format(a, b, c))
plt.show()

【问题讨论】:

    标签: python-3.x matplotlib text format


    【解决方案1】:

    我找到了解决办法:

    fig, ax = plt.subplots(figsize=(14, 8))
    a = 2.003
    b = 5.551
    c = -6.661
    plt.text(0.5, 0.5, "${0:f}^{{{1:+f}}}_{{{2:f}}}$".format(a,b,c))
    plt.show()
    

    【讨论】:

      猜你喜欢
      • 2019-07-11
      • 1970-01-01
      • 2012-10-29
      • 2013-09-09
      • 1970-01-01
      • 1970-01-01
      • 2013-01-17
      • 2021-01-04
      • 1970-01-01
      相关资源
      最近更新 更多