Skip to content

Commit

Permalink
show figs
Browse files Browse the repository at this point in the history
Now, plot functions don't show figures but return fig object. Added show() to display them.
  • Loading branch information
pavolgaj committed Mar 26, 2024
1 parent 5f51946 commit 07e2b21
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion examples/fit_example.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()
3 changes: 3 additions & 0 deletions examples/fit_quad_example.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -44,3 +46,4 @@
quad.Plot(trans = False)
#plot of residual O-C, without transformation of x axis
quad.PlotRes(trans = False)
mpl.show()
13 changes: 8 additions & 5 deletions gui/ocfit-gui.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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!')
Expand All @@ -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!')
Expand Down Expand Up @@ -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()

0 comments on commit 07e2b21

Please sign in to comment.