Python 具有不同标记大小的误差条

Python errorbar with varied marker size

我用python errorbar画图,但是参数markersize只能是标量不能是数组,这意味着所有的数据点都有相同的标记大小.我想知道如何将不同的 markersize 分配给不同的数据点?

ax.errorbar(x,y,xerr=[xlow,xup],yerr=[ylow,yup],color='r',ls='None',marker='o',markersize=5.)

如果我将标记大小设置为 5.0*y,我该如何让它发挥作用?

为什么不单独绘制误差线和标记?

import matplotlib.pyplot as plt
import numpy as np

#create x and y values
xval = np.arange(1,10)
yval = np.square(xval)
#define error bars and markersize
yerrmi = np.abs(np.cos(xval) * xval)
yerrpl = np.abs(np.sin(xval) * xval)
yerr = np.stack([yerrpl, yerrmi])
markerpl = 5 * yval

#plot error bars
plt.errorbar(xval, yval, yerr = yerr, ls = "None", color = "r")
#plot scatter plot
plt.scatter(xval, yval, s = 5 * yval, marker = "h", color = "r")

plt.show()

输出: