本文整理匯總了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)