From 07e2b214567f6b86a18c40217b093e347db05965 Mon Sep 17 00:00:00 2001 From: git Date: Tue, 26 Mar 2024 10:33:14 +0100 Subject: [PATCH] show figs Now, plot functions don't show figures but return fig object. Added show() to display them. --- examples/fit_example.py | 3 ++- examples/fit_quad_example.py | 3 +++ gui/ocfit-gui.py | 13 ++++++++----- 3 files changed, 13 insertions(+), 6 deletions(-) mode change 100644 => 100755 examples/fit_example.py mode change 100644 => 100755 examples/fit_quad_example.py diff --git a/examples/fit_example.py b/examples/fit_example.py old mode 100644 new mode 100755 index 6e8dbff..11e7d1f --- a/examples/fit_example.py +++ b/examples/fit_example.py @@ -1,5 +1,6 @@ from OCFit import OCFit, FitLinear import numpy as np +import matplotlib.pyplot as mpl #generating data E = np.arange(0, 100, 1) #epochs @@ -47,4 +48,4 @@ #figure with original O-C with fit without transformation of x axis #together with residue and 2nd axis in epochs fit.Plot(trans = False,with_res=True,double_ax=True) - +mpl.show() diff --git a/examples/fit_quad_example.py b/examples/fit_quad_example.py old mode 100644 new mode 100755 index f23d968..eb4599f --- a/examples/fit_quad_example.py +++ b/examples/fit_quad_example.py @@ -1,5 +1,6 @@ from OCFit import FitQuad, FitLinear import numpy as np +import matplotlib.pyplot as mpl #generate data E = np.arange(0, 100, 1) #epochs @@ -28,6 +29,7 @@ lin.Plot(trans = False) #plot of residual O-C, without transformation of x axis lin.PlotRes(trans = False) +mpl.show() #usage of class FitQuad #as estimation of linear ephemeris the resault from FitLinear are used @@ -44,3 +46,4 @@ quad.Plot(trans = False) #plot of residual O-C, without transformation of x axis quad.PlotRes(trans = False) +mpl.show() diff --git a/gui/ocfit-gui.py b/gui/ocfit-gui.py index cfdc4c6..e389a8a 100755 --- a/gui/ocfit-gui.py +++ b/gui/ocfit-gui.py @@ -1,8 +1,8 @@ #!/usr/bin/python3 #main file for GUI for OCFit class -#update: 19.9.2022 -# (c) Pavol Gajdos, 2018-2022 +#update: 26.3.2024 +# (c) Pavol Gajdos, 2018-2024 import tkinter as tk import tkinter.ttk @@ -870,6 +870,7 @@ def plot0(f=None): if not 'err' in data and 'w' in data: oc.Plot(name=f,trans=trans,weight=data['w'],min_type=True) else: oc.Plot(name=f,trans=trans,min_type=True) + if f is None: mpl.show() def save0(f=None): #save O-Cs calculated according to initial ephemeris @@ -1398,7 +1399,7 @@ def plotS(f=None): if not 'err' in data and 'w' in data: simple.Plot(name=f,trans=trans,weight=data['w'],min_type=True) else: simple.Plot(name=f,trans=trans,min_type=True) - + if f is None: mpl.show() def plotRS(f=None): #plot residual O-Cs after linear / quadratic fit @@ -1407,7 +1408,7 @@ def plotRS(f=None): if not 'err' in data and 'w' in data: simple.PlotRes(name=f,trans=trans,weight=data['w'],min_type=True) else: simple.PlotRes(name=f,trans=trans,min_type=True) - + if f is None: mpl.show() def sumS(f=None): #summary for linear / quadratic fit @@ -3915,6 +3916,7 @@ def plot(f=None): if min(w)==max(w): ocf.Plot(name=f,trans=trans,weight=w,min_type=True) else: ocf.Plot(name=f,trans=trans,weight=w,trans_weight=True,min_type=True) else: ocf.Plot(name=f,trans=trans,min_type=True) + if f is None: mpl.show() except KeyError: mpl.close() tkinter.messagebox.showerror('Plot O-C','Fit the model!') @@ -3940,6 +3942,7 @@ def plotR(f=None): if min(w)==max(w): ocf.PlotRes(name=f,trans=trans,weight=w,min_type=True) else: ocf.PlotRes(name=f,trans=trans,weight=w,trans_weight=True,min_type=True) else: ocf.PlotRes(name=f,trans=trans,min_type=True) + if f is None: mpl.show() except KeyError: mpl.close() tkinter.messagebox.showerror('Plot new O-C','Fit the model!') @@ -4395,7 +4398,7 @@ def summary(f=None): #label Label3=tk.Label(master) Label3.place(relx=0.09,rely=1-24/mheight,relheight=l2height/mheight,relwidth=0.9) -Label3.configure(text='(c) Pavol Gajdos, 2018 - 2022') +Label3.configure(text='(c) Pavol Gajdos, 2018 - 2024') Label3.configure(font=('None',9)) tk.mainloop()