当前位置: 首页>>代码示例>>Python>>正文


Python Graph.remove_plot方法代码示例

本文整理汇总了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 = []
开发者ID:navigator8972,项目名称:nao_writing,代码行数:70,代码来源:TeachMe.py

示例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)
开发者ID:iverasp,项目名称:it3708,代码行数:68,代码来源:MTSPGraph.py


注:本文中的kivy.garden.graph.Graph.remove_plot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。