python 添加图例_Python | 在图例标签中添加Sigma

本文介绍了如何在Python的matplotlib库中使用命令添加希腊字母Σ(Sigma)到图表的图例中,特别是在概率领域的数据可视化中。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

python 添加图例

Sigma (𝜎) is very often used greek mathematical letters and has a higher repetition in probability. In this article, we are going to add 𝜎 using a command in matplotlib.

Sigma(𝜎)是希腊数学字母中经常使用的字母,其重复率更高。 在这篇文章中,我们将添加σ在matplotlib使用命令。

plt.text(3, 0.4, r'$\sigma=100$')
#Adding 𝜎 as text

Python | Adding Sigma in Plot Label (1)
plt.title('Errorbar with 'r'$\sigma=100$')
#Adding 𝜎 in title of the figure

Python | Adding Sigma in Plot Label (2)
plt.xlabel('Time ('r'$\sigma=100)$')
#Adding 𝜎 in title of the figure

Python | Adding Sigma in Plot Label (3)
plt.ylabel('Variation ('r'$\sigma=100)$')
#Adding 𝜎 in title of the figure

Python | Adding Sigma in Plot Label (4)

在情节标签中添加omega的Python代码 (Python code for adding omega in plot label)

import numpy as np
import matplotlib.pyplot as plt

x = np.arange(0.1, 5, 0.1)
y = np.sin(x)*np.exp(-x)

# In text
plt.figure()
plt.plot(x,y, 'o', color='purple')
plt.title('Errorbar')
plt.text(4, 0.0, r'$\sigma=100$')
plt.grid()
plt.show()

# In title
plt.figure()
plt.plot(x,y, 'o', color='purple')
plt.title('Plotting with 'r'$\sigma=100$')
plt.grid()
plt.show()

# In x-axis label
plt.figure()
plt.plot(x,y, 'o', color='purple')
plt.xlabel('Time ('r'$\sigma=100)$')
plt.grid()
plt.show()

# In y-axis label
plt.figure()
plt.plot(x,y, 'o', color='purple')
plt.ylabel('Function ('r'$\sigma=100)$')
plt.grid()
plt.show()

Output:

输出:

Output is as figure


翻译自: https://www.includehelp.com/python/adding-sigma-in-plot-label.aspx

python 添加图例

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值