Closedown
This commit is contained in:
@@ -1,57 +1,51 @@
|
||||
import random
|
||||
|
||||
|
||||
|
||||
def add_plot(x,y, name=None):
|
||||
|
||||
|
||||
def clear_plot():
|
||||
title = "test"
|
||||
plots = get_plots(title = title)
|
||||
if len(plots)>0:
|
||||
plots[0].clear()
|
||||
|
||||
|
||||
def add_plot(x,y, name=None, clear = False):
|
||||
title = "test"
|
||||
plots = get_plots(title = title)
|
||||
p = None
|
||||
if len(plots)==0:
|
||||
p = plot(None,name=name, title = title)[0]
|
||||
p.setLegendVisible(True)
|
||||
p = plot(None,name=name, title = title)[0]
|
||||
p.getAxis(p.AxisId.X).setRange(-50,150)
|
||||
p.getAxis(p.AxisId.Y).setRange(-50,150)
|
||||
p.setLegendVisible(True)
|
||||
else:
|
||||
p = plots[0]
|
||||
p.addSeries(LinePlotSeries(name))
|
||||
s = p.getSeries(name)
|
||||
p = plots[0]
|
||||
if clear:
|
||||
p.clear()
|
||||
p.addSeries(LinePlotSeries(name))
|
||||
s = p.getSeries(name)
|
||||
s.setLinesVisible(False)
|
||||
s.setPointSize(3)
|
||||
s.setData(x, y)
|
||||
#p.update(False)
|
||||
#time.sleep(0.01) #So s.getColor() is updated
|
||||
|
||||
s.setData(x, y)
|
||||
|
||||
#Bounding box
|
||||
x1,x2,y1,y2 = min(x), max(x), min(y), max(y)
|
||||
bb = LinePlotSeries(name + " BBox" )#, s.color)
|
||||
p.addSeries(bb)
|
||||
x1,x2,y1,y2 = min(x), max(x), min(y), max(y)
|
||||
#In the first time the plot shows, it takes some time for the color to be assigned
|
||||
while s.color is None:
|
||||
time.sleep(0.001)
|
||||
bb = LinePlotSeries(name + " BBox", s.color)
|
||||
p.addSeries(bb)
|
||||
bb.setLineWidth(2)
|
||||
bb.setData([x1,x2, x2, x1, x1], [y1, y1, y2, y2, x1])
|
||||
|
||||
#fork
|
||||
#bb.setColor(s.color)
|
||||
|
||||
def update_colors(name):
|
||||
title = "test"
|
||||
p=get_plots(title = title)[0]
|
||||
p.update(False)
|
||||
s = p.getSeries(name)
|
||||
bb =p.getSeries(name + " BBox" )#, s.color)
|
||||
bb.setColor(s.color)
|
||||
bb.setData([x1,x2, x2, x1, x1], [y1, y1, y2, y2, y1])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
clear_plot()
|
||||
x=[]
|
||||
y=[]
|
||||
|
||||
for step in range(1,10):
|
||||
for step in range(1,5):
|
||||
x=[]
|
||||
y=[]
|
||||
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))
|
||||
|
||||
|
||||
#for step in range(1,10):
|
||||
# update_colors("Step " + str(step))
|
||||
y.append(random.random() * 100/ step)
|
||||
add_plot (x,y,"Step " + str(step))
|
||||
Reference in New Issue
Block a user