python - Python 绘图问题:清除
问题描述
我这几天都遇到问题了
该程序允许您检索数据、创建数据并将其显示在图形上。
我这样做是因为无论我们按下什么按钮,我们都可以显示 2 条曲线或 3 条曲线,然后它就会显示出来。
因此,我的问题是要知道在当前状态下是否可以删除图表?如果程序写得比较好?我还应该怎么做?我的最后一个问题是,我想创建一个允许直接从图中检索数据的函数,这可能吗?
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()
解决方案
推荐阅读
- python - Python Selenium:元素不可点击
- r - 如何循环将列添加到数据框中的命令?
- html - 电子邮件基础:垂直对齐不适用于移动设备
- ruby-on-rails - 如何使用选择但允许模型中的所有字段
- elasticsearch - Filebeat 默认仪表板:未找到结果
- rasa-nlu - 使用 rasa NLU 将用户请求的自定义操作提取为实体
- reactjs - ReactJS 上下文 > 从状态函数中引用最新状态值
- java - 使用 Java-Large 文件查询 JSON 文件
- reactjs - 如何通过reactjs在表格中正确显示json结果
- javascript - 使用 JS 修改表单标签文本,仅使用“for”属性作为选择器