python打印问题:清除

mwngjboj  于 2021-07-14  发布在  Java
关注(0)|答案(0)|浏览(210)

我已经遇到问题好几天了,
该程序允许您检索数据、创建数据并将其显示在图形上。
我这样做是因为我们可以显示2条曲线或3条曲线,无论我们按按钮和presto它显示。
因此,我的问题是,在当前状态下,是否可以删除这些图?如果程序写得比较好?不然我该怎么办?最后一个问题,我想创建一个函数,可以直接从图中检索数据,可以吗?

self.fig = Figure(figsize=(6.25,4.16), dpi=96)
ax = self.fig.add_subplot(111)

def ref():
    is_cal = messagebox.askquestion("Mesure Référence","Le calibrage à t'il était fait ?")

    if is_cal == "yes":

        print("Cal = TRUE")

        FUNCTION GET DATA NO ISSUES WITH IT return X Y

        #Check if data is OK, matching number, not empty array
        if y.all():
            if x.all():

                ax.plot(x, y, label="Ref S21 Start {} Hz Pwr {}dBm Bw {} Stop {} Hz".format(self.startfreq, self.power ,self.rbw ,self.endfreq))
                #ax.set_title("DUT ??? : ??/??/????")
                ax.set_xscale("log")
                ax.set_xlabel("Fréquence (Hz)")
                ax.set_ylabel("Atténuation (dB)")
                ax.legend()
                ax.grid(True, which="both", ls="-")
                graph = FigureCanvasTkAgg(self.fig, master=canvas_display)
                graph.draw()
                graph.get_tk_widget().place(x=1,y=1)

                self.pdf = self.fig

        else:
            print("Erreur")

        subsection_min['text'] = "  Atténuation minimum : {} dB".format(round(self.Minimum(y),1))
        subsection_max['text'] = "  Atténuation maximum : {} dB".format(round(self.Maximum(y),1))
        subsection_moy['text'] = "  Atténuation moyenne : {} dB".format(round(self.Average(y),1))

        self.averageref_value = self.Average(y)

    if is_cal == "no":
        print("CAL = FALSE")
        messagebox.showerror("Mesure Référence", "Il est impossible de trouver la référence si le calibrage n'est pas correct / initialisé")

def dut():

    print("Print new graph")

    FUNCTION GET DATA NO ISSUES WITH IT return X Y

    self.x = x
    self.y = y

    is_ref = messagebox.askquestion("Mesure DUT", "La mesure de référence à t-elle était faite ?")

    if is_ref == "yes":

        #Check if data is OK, matching number, not empty array
        if y.all():
            if x.all():

                #Duplicate

                self.nbdut = self.nbdut + 1
                ax.plot(x, y, label="DUT {} S21 Start {} Hz Pwr {}dBm Bw {} Stop {} Hz".format(self.nbdut, self.startfreq, self.power ,self.rbw ,self.endfreq))
                ax.set_title("PLOT 1 : 22/04/2021")
                ax.set_xscale("log")
                ax.set_xlabel("Fréquence (Hz)")
                ax.set_ylabel("Atténuation (dB)")
                ax.legend()
                ax.grid(True, which="both", ls="-")
                graph = FigureCanvasTkAgg(self.fig, master=canvas_display)
                graph.draw()
                graph.get_tk_widget().place(x=1,y=1)

                self.pdf = self.fig

        else:
            print("Erreur")

        subsection_min['text'] = "  Atténuation minimum : {} dB".format(round(self.Minimum(y),1))
        subsection_max['text'] = "  Atténuation maximum : {} dB".format(round(self.Maximum(y),1))
        subsection_moy['text'] = "  Atténuation moyenne : {} dB".format(round(self.Average(y),1))

        self.averagedut_value = self.Average(y)

    if is_ref == "no":

        messagebox.showerror("Mesure DUT", "Lancez d'abord la mesure de référence avant la mesure DUT")

def raz():

    print("RAZ")
    #self.fig = Figure(figsize=(6.25,4.16), dpi=96)
    self.fig.ax().close()

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题