本文整理汇总了Python中kivy.garden.graph.Graph.remove_plot方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.remove_plot方法的具体用法?Python Graph.remove_plot怎么用?Python Graph.remove_plot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.garden.graph.Graph
的用法示例。
在下文中一共展示了Graph.remove_plot方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DrawScreen
# 需要导入模块: from kivy.garden.graph import Graph [as 别名]
# 或者: from kivy.garden.graph.Graph import remove_plot [as 别名]
#.........这里部分代码省略.........
size_hint=(.1, .1), pos_hint = {'center_y': .9, 'center_x': .5 })
self.nao_btn.opacity = 1
self.nao_btn.disabled = False
self.nao_btn.bind(on_press=self.on_nao_turn)
self.graph_layout.add_widget(self.nao_btn)
self.graph_layout.add_widget(self.graph)
self.button_layout.add_widget(self.clear_graph)
# self.button_layout.add_widget(self.animate_btn)
self.button_layout.add_widget(self.gap_btn1)
self.button_layout.add_widget(self.next_graph)
self.button_layout.add_widget(self.gap_btn2)
self.button_layout.add_widget(self.eraser)
self.draw_layout.add_widget(self.child_btn)
self.draw_layout.add_widget(self.painterbox)
return
def on_nao_turn(self, *args):
if self.on_send_char is not None:
#call this
self.on_send_char()
return
def create_plot(self, *args):
return LinePlot(color=[0, 0.443, 0.737, 1], line_width = 3) # orange
def clear_plot(self, *args):
# self.graph.remove_plot(self.plot)
# self.graph.remove_plot(self.plot1)
for plot in self.plots:
self.graph.remove_plot(plot)
self.plots = []
return
def next_plot(self, *args):
self.clear_plot()
self.painterbox.clear_letter()
self.eraser.disabled = True
app.counter += 1
if app.counter > 14 or app.counter >= len(self.keys):
app.sm.current = 'fs'
else:
self.curr_char = self.keys[app.counter]
self.curr_data = self.data[self.curr_char][0]
self.draw(self.curr_data)
return
def on_enter(self):
data_file = os.path.join(app.resource_folder, 'file_p', app.file_p)
self.data = cp.load(open(data_file, 'rb'))
self.keys = self.data.keys()
self.curr_char = self.keys[0]
self.curr_data = self.data[self.curr_char][5]
self.draw(self.curr_data)
return
def max_min_range(self, data):
d = 0
x_ma = []
y_mi = []
示例2: MTSPGraph
# 需要导入模块: from kivy.garden.graph import Graph [as 别名]
# 或者: from kivy.garden.graph.Graph import remove_plot [as 别名]
class MTSPGraph(BoxLayout):
green = [0, 1, 0, 1]
blue = [0, 0, 1, 1]
def __init__(self):
super(MTSPGraph, self).__init__()
self.graph = Graph(
xlabel="Distance",
ylabel="Cost",
x_ticks_minor=0,
x_ticks_major=10000,
y_ticks_minor=0,
y_ticks_major=100,
y_grid_label=True,
x_grid_label=True,
padding=5,
x_grid=True,
y_grid=True,
xmin=0,
xmax=200000,
ymin=0,
ymax=2000,
size=(1200, 800)
)
self.plot = []
self.plot.append(MeshLinePlot(color=self.green))
self.plot.append(MeshLinePlot(color=self.blue))
self.plot[1]._set_mode('points')
self.orientation = 'vertical'
self.add_widget(self.graph)
def generate_color(self, n):
return [random() for _ in range(4)]
def add_datas(self, fronts, end=False):
if end:
for plot in self.plot:
self.graph.remove_plot(plot)
self.plot = []
## add first pareto front
self.plot.append(MeshLinePlot(color=self.green))
else:
self.plot[0].points.clear()
self.plot[1].points.clear()
for individual in fronts[0].getIndividuals():
self.plot[0].points.append((individual.getDistanceValue(), individual.getCostValue()))
## add all other fronts
if end:
for i in range(1, len(fronts)):
self.plot.append(MeshLinePlot(color=self.generate_color(i)))
#self.plot[i]._set_mode('points')
for individual in fronts[i].getIndividuals():
self.plot[i].points.append((individual.getDistanceValue(), individual.getCostValue()))
else:
for i in range(1, len(fronts)):
for individual in fronts[i].getIndividuals():
self.plot[1].points.append((individual.getDistanceValue(), individual.getCostValue()))
for plot in self.plot:
self.graph.add_plot(plot)