Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/355.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将图例添加到pyplot.errorbar_Python_Numpy_Matplotlib - Fatal编程技术网

Python 将图例添加到pyplot.errorbar

Python 将图例添加到pyplot.errorbar,python,numpy,matplotlib,Python,Numpy,Matplotlib,大家好!目标是将图例添加到图表中。y和YER分别标记为“平均值”和“标准偏差” 你试过什么?添加一个label=“mean±sd”并调用ax.legend()是如何让人不满意的呢?@DizietAsahi这是一个很好的解决方案。另一个问题是,如何键入带下划线的加号? import numpy as np import matplotlib.pyplot as plt # example data x = np.arange(0.1, 4, 0.5) y = np.exp(-x) yerr =

大家好!目标是将图例添加到图表中。y和YER分别标记为“平均值”和“标准偏差”

你试过什么?添加一个
label=“mean±sd”
并调用
ax.legend()
是如何让人不满意的呢?@DizietAsahi这是一个很好的解决方案。另一个问题是,如何键入带下划线的加号?
import numpy as np
import matplotlib.pyplot as plt

# example data
x = np.arange(0.1, 4, 0.5)
y = np.exp(-x)
yerr = 0.1*np.random.rand(8)

fig, ax = plt.subplots()
ax.errorbar(x, y, linestyle='none', marker='*', yerr=yerr)
plt.show()