Files
sf-op/script/test/MultiplePlot.py
2016-06-16 17:31:45 +02:00

42 lines
971 B
Python

import random
title = "test"
def add_plot(x,y, name=None):
global title
plots = get_plots(title = title)
if len(plots)==0:
p = plot(None,name=name, title = title)[0]
p.setLegendVisible(True)
else:
p = plots[0]
p.addSeries(LinePlotSeries(name))
s = p.getSeries(name)
s.setLinesVisible(False)
s.setPointSize(3)
s.setData(x, y)
#p.update(False)
time.sleep(0.001) #So s.getColor() is updated
x1,x2,y1,y2 = min(x), max(x), min(y), max(y)
bb = LinePlotSeries(name + " BBox", s.getColor())
p.addSeries(bb)
bb.setLineWidth(2)
bb.setData([x1,x2, x2, x1, x1], [y1, y1, y2, y2, x1])
x=[]
y=[]
for step in range(1,10):
x=[]
y=[]
for i in range(20):
x.append(random.random() * 100 / step)
y.append(random.random() * 100/ step)
add_plot (x,y,"Step " + str(step))