看来
NumVal,
NumData并且
NumDataSource需要
ErrorBars从头开始创建:
# References for X and Yxvalues = Reference(<worksheet>, min_col=<xcol>, min_row=<min>, max_row=<max>)yvalues = Reference(<worksheet>, min_col=<ycol>, min_row=<min>, max_row=<max>) plus = [<list of error values for plus>]minus = [<list of error values for minus>]# Convert lists of error values to ErrorBars objecterrorbars = list2errorbars(plus, minus, errDir='y')# Create series data and set error barseries = SeriesFactory(yvalues, xvalues, title="y direction error")series.errBars = errorbarsdef list2errorbars(plus, minus, errDir='y', errValType='cust'): "Returns ErrorBar from lists of error values" #Convert to list of NumVal numvals_plus = [NumVal(i, None, v=x) for i,x in enumerate(plus)] numvals_minus = [NumVal(i, None, v=x) for i,x in enumerate(minus)] # Convert to NumData nd_plus = NumData(pt=numvals_plus) nd_minus = NumData(pt=numvals_minus) # Convert to NumDataSource nds_plus = NumDataSource(numLit=nd_plus) nds_minus = NumDataSource(numLit=nd_minus) return ErrorBars(plus=nds_plus, minus=nds_minus, errDir=errDir, errValType=errValType)
完整的示例代码:https :
//github.com/uskysd/openpyxl-errorbar
由于我也找不到好的文档,因此我从源代码中找出来。让我知道是否有更简单的方法可以做到这一点。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)