【问题标题】:Add limits to the integration symbol in matplotlib.pyplot.ylabel()在 matplotlib.pyplot.ylabel() 中为积分符号添加限制
【发布时间】:2018-02-02 16:50:52
【问题描述】:

我希望 ylabel 采用下图中的形式。

我已经使用下面的行来获取 ylabel 上的整数符号,没有限制。

plt.ylabel(r'$\int du/(1+u^{2})$')

我需要知道如何在整数符号中引入极限 0 和 x。

【问题讨论】:

    标签: python matplotlib latex python-3.6 tex


    【解决方案1】:

    我看到了两种可能性。首先,您可以使用通用的_^ 作为下限和上限:

    plt.ylabel(r'$\int_0^y du/(1+u^{2})$')
    

    不过,我个人偶尔不喜欢这种格式(在我的设置中)。您可以在 matplotlib 中启用 Latex,然后用它标记轴,如果这对您来说是一样的。举个例子(为了简单起见,它当然不是正确的标签..)

    import matplotlib.pyplot as plt
    import matplotlib as mpl
    import numpy as np
    
    mpl.rcParams['text.usetex'] = True
    b = np.array([1,2,3,4,5])
    
    plt.plot(b,b)
    plt.ylabel(r'$\int\limits_0^x  du/{(1+u^2)}$')
    plt.show()
    

    如果您知道任何 Latex 并想更改格式并尝试一些东西,您可以玩一下,例如:

    plt.ylabel(r'$\int\limits_{\scriptscriptstyle 0}^{\scriptstyle x}  \frac{du}{1+u^2}$', size=12)
    

    虽然老实说,乳胶支持有点糟糕。

    【讨论】:

      猜你喜欢
      • 2021-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-20
      • 2012-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多