def refresh_integral_markings(dis, markings_list, curveplot):
for m in markings_list:
if m in curveplot.markings:
curveplot.remove_marking(m)
markings_list.clear()
def add_marking(a):
markings_list.append(a)
curveplot.add_marking(a)
for di in dis:
if di is None:
continue # nothing to draw
color = QColor(di.get("color", "red"))
for el in di["draw"]:
if el[0] == "curve":
bs_x, bs_ys, penargs = el[1]
curve = pg.PlotCurveItem()
curve.setPen(pg.mkPen(color=QColor(color), **penargs))
curve.setZValue(10)
curve.setData(x=bs_x, y=bs_ys[0])
add_marking(curve)
elif el[0] == "fill":
(x1, ys1), (x2, ys2) = el[1]
phigh = pg.PlotCurveItem(x1, ys1[0], pen=None)
plow = pg.PlotCurveItem(x2, ys2[0], pen=None)
color = QColor(color)
color.setAlphaF(0.5)
cc = pg.mkBrush(color)
pfill = pg.FillBetweenItem(plow, phigh, brush=cc)
pfill.setZValue(9)
add_marking(pfill)
elif el[0] == "line":
(x1, y1), (x2, y2) = el[1]
line = pg.PlotCurveItem()
line.setPen(pg.mkPen(color=QColor(color), width=4))
line.setZValue(10)
line.setData(x=[x1[0], x2[0]], y=[y1[0], y2[0]])
add_marking(line)
elif el[0] == "dot":
(x, ys) = el[1]
dot = pg.ScatterPlotItem(x=x, y=ys[0])
dot.setPen(pg.mkPen(color=QColor(color), width=5))
dot.setZValue(10)
add_marking(dot)
评论列表
文章目录