示例#1
0
 def build(self):
     fl = BoxLayout(orientation="vertical")
     a = Button(text="press me", height=40, size_hint_y=None)
     a.bind(on_press=callback)
     nav1 = NavigationToolbar2Kivy(canvas)
     nav2 = NavigationToolbar2Kivy(canvas2)
     fl.add_widget(nav1.actionbar)
     fl.add_widget(canvas)
     fl.add_widget(nav2.actionbar)
     fl.add_widget(canvas2)
     fl.add_widget(a)
     return fl
示例#2
0
    def updateChart(self, clock=0):
        print(Global.array.shape)
        if Global.array.shape[0] <= 1:
            label = Label(text='Nicht genug Daten')
            self.my_box.clear_widgets()
            self.my_box.add_widget(label)
            return

        #self.data, self.X, self.Y = sqlPort.getValuesBySurface(self.time)
        self.data = np.sum(Global.array, 2) / Global.config["ybounds"]
        print(self.data)

        fig, ax = plt.subplots(facecolor='black')

        my_mpl_kivy_widget = FigureCanvas(fig)

        ax.set_xlabel('x', fontsize=15)
        ax.set_ylabel('y', fontsize=15)

        #CS = ax.contourf(self.X, self.Y, self.data)
        CS = ax.contourf(self.data)
        cbar = plt.colorbar(CS)

        cbar.set_label('amplidtude')

        nav2 = NavigationToolbar2Kivy(my_mpl_kivy_widget)

        self.my_box.clear_widgets()
        self.my_box.add_widget(nav2.actionbar)
        self.my_box.add_widget(my_mpl_kivy_widget)
示例#3
0
    def create_plot(self):

        fig, ax = plt.subplots()

        xCoords = [1, 2, 3]
        yCoords = [1, 4, 9]

        # Plot the data
        lineA = ax.plot(xCoords,
                        yCoords,
                        color='blue',
                        marker='o',
                        markerfacecolor='blue',
                        markersize=6)
        ax.set_ylim([0, 10])

        # Connect Matplotlib events to our own callbacks using Matplotlib's mpl_connect method
        fig.canvas.mpl_connect('button_press_event', press)
        fig.canvas.mpl_connect('button_release_event', release)
        fig.canvas.mpl_connect('key_press_event', keypress)
        fig.canvas.mpl_connect('key_release_event', keyup)
        fig.canvas.mpl_connect('motion_notify_event', motionnotify)
        fig.canvas.mpl_connect('resize_event', resize)
        fig.canvas.mpl_connect('scroll_event', scroll)
        fig.canvas.mpl_connect('figure_enter_event', figure_enter)
        fig.canvas.mpl_connect('figure_leave_event', figure_leave)
        fig.canvas.mpl_connect('close_event', close)

        canvas = fig.canvas

        # Add each navigation toolbar and canvas to our BoxLayout
        nav1 = NavigationToolbar2Kivy(canvas)
        self.add_widget(nav1.actionbar)
        self.add_widget(canvas)
示例#4
0
 def specific(self, index, unused):
     self.boxp2 = RelativeLayout()
     fig2, ax2 = plt.subplots()
     ax2.set_xlabel("PC1")
     ax2.set_ylabel("PC2")
     ax2.plot(file2[:, 0], file2[:, 1], "o")
     for j in huling[index]:
         ax2.plot(np.array(dur[index])[j, 0],
                  np.array(dur[index])[j, 1],
                  marker='o',
                  linestyle='-',
                  markerfacecolor="blue",
                  color='red')
     self.win2 = fig2.canvas
     # FigureCanvasKivyAgg(ax1.gcf(), size_hint=(1, 0.9), pos_hint={"top": 1})
     self.boxp2.add_widget(self.win2)
     closeButton2 = Button(text="Close the pop-up",
                           size_hint=(0.3, 0.1),
                           pos=(0, 0))
     self.one2 = NavigationToolbar2Kivy(self.win2)
     self.boxp2.add_widget(self.one2.actionbar)
     self.boxp2.add_widget(closeButton2)
     self.pop_up2 = Popup(title="Visualization", content=self.boxp2)
     self.pop_up2.open()
     closeButton2.bind(on_press=self.pop_up2.dismiss)
示例#5
0
文件: main.py 项目: S7rizh/DE_Compas
 def select_plot(self, plot):
     if plot is None:
         return
     self.figure_box.clear_widgets()
     canvas = FigureCanvasKivyAgg(plot)
     self.figure_box.add_widget(canvas)
     self.figure_box.add_widget(NavigationToolbar2Kivy(canvas).actionbar)
示例#6
0
    def build(self):
        data = np.random.random((10, 10))

        # Create the widgets. We need a vertical box to arrange the navigation toolbar
        hbox = BoxLayout()
        vbox = BoxLayout(orientation="vertical")
        label = Label(text="Click on the plot as many times as you want!")

        # Create the figure.
        fig = Figure()
        axes = fig.add_subplot()
        axes.imshow(data)
        canvas = FigureCanvasKivyAgg(fig)
        nav = NavigationToolbar2Kivy(canvas)

        # Add them to a container.
        vbox.add_widget(canvas)
        vbox.add_widget(nav.actionbar)
        hbox.add_widget(label)
        hbox.add_widget(vbox)

        # Add the callback of the canvas.
        canvas.mpl_connect("button_press_event", on_canvas_click)
        canvas.draw()

        # Return the top container. This can be any widget
        return hbox
示例#7
0
    def __init__(self, **kwargs):
        super(Graphs, self).__init__(**kwargs)

        self.graph = BoxLayout(orientation="vertical")
        self.fig, (self.ax, self.ax2) = plt.subplots(nrows=2, sharex=True)
        self.ids.graph.add_widget(self.graph)
        canvas = self.fig.canvas
        nav1 = NavigationToolbar2Kivy(canvas)
        self.graph.add_widget(nav1.actionbar)
        self.graph.add_widget(canvas)
        self.fig.canvas.mpl_connect('key_press_event', self.keypress)
示例#8
0
 def set_map(self):
     """
     Assign appropriate figure map to screen
     :return: None
     """
     box = self.ids.visual_box
     temp = FigureCanvasKivyAgg(self.plt_var)
     box.add_widget(temp)
     navigation = NavigationToolbar2Kivy(temp)
     box.add_widget(navigation.actionbar)
     map_button = self.ids.map_button
     map_button.disabled = True
示例#9
0
    def build(self):
        fl = BoxLayout(orientation="vertical")

        self.btn1 = Button(text="Update", height=40, size_hint_y=None)
        self.btn1.bind(on_press=callback)

        self.tekstvak = TextInput(height=30, size_hint_y=None, multiline=False)

        nav1 = NavigationToolbar2Kivy(canvas)

        fl.add_widget(nav1.actionbar)
        fl.add_widget(canvas)
        fl.add_widget(self.tekstvak)
        fl.add_widget(self.btn1)
        return fl
示例#10
0
 def pop1(self, button):
     self.boxp1 = RelativeLayout()
     fig1, ax1 = plt.subplots()
     ax1.set_xlabel("PC1")
     ax1.set_ylabel("PC2")
     for k in range(len(file4)):
         ax1.plot(file4[k][0], file4[k][1], marker="o", color="blue")
     self.win1 = fig1.canvas
     #FigureCanvasKivyAgg(ax1.gcf(), size_hint=(1, 0.9), pos_hint={"top": 1})
     self.boxp1.add_widget(self.win1)
     closeButton1 = Button(text="Close the pop-up",
                           size_hint=(0.15, 0.06),
                           pos=(0, 0))
     self.one1 = NavigationToolbar2Kivy(self.win1)
     self.boxp1.add_widget(self.one1.actionbar)
     self.boxp1.add_widget(closeButton1)
     self.pop_upp = Popup(title="Visualization", content=self.boxp1)
     self.pop_upp.open()
     closeButton1.bind(on_press=self.pop_upp.dismiss)
示例#11
0
    def updateChart(self, clock=0):
        start_time = time.time()
        self.getPosPara()
        self.updateLabel()
        plt.figure(1)

        print(self.X, self.Y)

        self.data = Global.array[self.Y, self.X]

        fig, ax = plt.subplots(facecolor='black')

        my_mpl_kivy_widget = FigureCanvas(fig)

        ax.set_xlabel('time in 14/1024 \u03BCs', fontsize=15)
        ax.set_ylabel('amplitude', fontsize=15)

        print("Here1", time.time() - start_time)
        start_time = time.time()

        major_ticks_x = np.arange(0, 1020, 100)
        major_ticks_y = np.arange(0, 1020, 100)
        minor_ticks = np.arange(0, 1020, 10)

        print("Here2", time.time() - start_time)
        start_time = time.time()

        ax.set_xticks(major_ticks_x)
        #ax.set_xticks(minor_ticks, minor=True)
        ax.set_yticks(major_ticks_y)
        #ax.set_yticks(minor_ticks, minor=True)
        print("Here3", time.time() - start_time)
        start_time = time.time()

        ax.grid()

        CS = ax.plot(self.data)

        nav1 = NavigationToolbar2Kivy(my_mpl_kivy_widget)

        self.my_box.clear_widgets()
        self.my_box.add_widget(nav1.actionbar)
        self.my_box.add_widget(my_mpl_kivy_widget)
示例#12
0
    def updateChart(self, clock=0):

        self.data, self.X, self.Y = sqlPort.getValuesBySurfaceTest()

        fig, ax = plt.subplots(facecolor='black')

        my_mpl_kivy_widget = FigureCanvas(fig)

        ax.set_xlabel('x', fontsize=15)
        ax.set_ylabel('y', fontsize=15)

        CS = ax.contourf(self.X, self.Y, self.data)
        cbar = plt.colorbar(CS)

        cbar.set_label('amplidtude')

        nav2 = NavigationToolbar2Kivy(my_mpl_kivy_widget)

        self.my_box.clear_widgets()
        self.my_box.add_widget(nav2.actionbar)
        self.my_box.add_widget(my_mpl_kivy_widget)
示例#13
0
    def build(self):
        global huling, dur
        self.box = RelativeLayout()
        fig, ax = plt.subplots()
        ax.set_xlabel("PC1")
        ax.set_ylabel("PC2")
        ax.plot(file2[:, 0], file2[:, 1], "o")
        for i, k in zip(range(len(huling)), range(len(dur))):
            for simplex in huling[i]:
                ax.plot(np.array(dur[k])[simplex, 0],
                        np.array(dur[k])[simplex, 1],
                        marker='o',
                        linestyle='-',
                        markerfacecolor="blue",
                        color='red')

        self.win = fig.canvas
        #FigureCanvasKivyAgg(fig.canvas, size_hint=(1, 0.9), pos_hint={"top": 1})
        self.box.add_widget(self.win)
        self.one = NavigationToolbar2Kivy(self.win)
        self.box1 = BoxLayout(orientation="horizontal")
        self.box1.add_widget(self.one.actionbar)
        self.box2 = BoxLayout(orientation="horizontal")
        #self.box2=GridLayout()
        self.bt3 = Button(text="scores plot",
                          size_hint=(0.15, 0.06),
                          pos=(0, 0))
        self.bt4 = Button(text="pathway list",
                          size_hint=(0.15, 0.06),
                          pos=(1, 0))
        self.box2.add_widget(self.bt3)
        self.bt3.bind(on_press=self.pop1)
        self.bt4.bind(on_press=self.pop)
        self.box2.add_widget(self.bt4)
        self.box.add_widget(self.box1)
        self.box.add_widget(self.box2)
        self.pop_up1 = Popup(title="Visualization", content=self.box)
        self.pop_up1.open()
示例#14
0
    def graphit(self):
        self.fig, (self.ax, self.ax2) = plt.subplots(nrows=2, sharex=True)
        self.ax2.set_xlabel('common xlabel')
        self.ax2.set_ylabel('common ylabel')
        self.sensors = Sensors()

        self.fig.canvas.mpl_connect('button_press_event', self.press)
        self.fig.canvas.mpl_connect('button_release_event', self.release)
        self.fig.canvas.mpl_connect('key_press_event', self.keypress)
        self.fig.canvas.mpl_connect('key_release_event', self.keyup)
        self.fig.canvas.mpl_connect('resize_event', self.resize)
        self.fig.canvas.mpl_connect('scroll_event', self.scroll)
        self.fig.canvas.mpl_connect('close_event', self.close)

        canvas = self.fig.canvas
        self.liveGraph = BoxLayout(orientation="vertical")
        nav1 = NavigationToolbar2Kivy(canvas)
        self.liveGraph.add_widget(nav1.actionbar)
        self.liveGraph.add_widget(canvas)
        self.ids.graph.add_widget(self.liveGraph)
        self.ax2.set_ylabel('common ylabel')

        self.graphData = pd.DataFrame(columns=('time', 'audio', 'temperature'))
        Clock.schedule_interval(self.refreshGraphData, 1)
示例#15
0
    def updateChart(self, clock):
        plt.figure(1)

        self.Y = np.arange(0, Global.config["scans"])
        self.X = np.arange(0, Global.config["ybounds"])
        self.data = Global.array[self.numberOfLine]

        fig, ax = plt.subplots(facecolor='black')

        my_mpl_kivy_widget = FigureCanvas(fig)

        ax.set_xlabel('x', fontsize=15)
        ax.set_ylabel('time', fontsize=15)

        CS = ax.contourf(np.transpose(self.data))
        cbar = plt.colorbar(CS)

        cbar.set_label('amplidtude')

        nav1 = NavigationToolbar2Kivy(my_mpl_kivy_widget)

        self.my_box.clear_widgets()
        self.my_box.add_widget(nav1.actionbar)
        self.my_box.add_widget(my_mpl_kivy_widget)
 def home(self, event):
     NavigationToolbar2Kivy.home(self, event)
     self.canvas.draw()
示例#17
0
 def __init__(self, **kwargs):
     super(ScatterGraph, self).__init__(**kwargs)
     self.figure, self.axes = plt.subplots()
     self.add_widget(NavigationToolbar2Kivy(self.figure.canvas).actionbar)
     self.add_widget(self.figure.canvas)