Skip to content

Commit 5612d68

Browse files
authored
Changed Plot GUI backend
VSManalyser.py:65: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
1 parent ff8a328 commit 5612d68

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

VSManalyser.py

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import numpy as np
22
import matplotlib.pyplot as plt
33
from scipy.optimize import curve_fit
4-
from tkinter import *
5-
from tkinter import filedialog
4+
from tkinter import filedialog, Tk, Button, Text
5+
6+
import matplotlib
7+
matplotlib.use('TkAgg') # replace the GUI backend
68

79

810
root=Tk() #call tkinter function
@@ -15,7 +17,6 @@ def Main():
1517

1618
# Open file
1719
file_path = filedialog.askopenfilename(initialdir="/") # get the file path
18-
#print(file_path)
1920

2021
# Read in raw data from VSM measurement
2122
raw_data = np.loadtxt(file_path)
@@ -55,24 +56,15 @@ def anisotropy_model(theta, k1, k2):
5556
txt_output = Text(root, height=17, width=43)
5657
txt_output.place(x=25,y=220)# place
5758

58-
txt_output.insert(END, ' Key Parameters ' + "\n\n")
59-
txt_output.insert(END, ' Saturation moment: {:.3f} Am^2'.format(saturation_moment) + "\n")
60-
txt_output.insert(END, ' Coercivity: {:.3f} T'.format(coercivity) + "\n")
61-
txt_output.insert(END, ' Remanence: {:.3f} Am^2'.format(remanence) + "\n")
62-
txt_output.insert(END, ' Magnetic moment: {:.3f} Am^2'.format(magnetic_moment) + "\n")
63-
txt_output.insert(END, ' Anisotropy constants: k1={:.3e} J/m^3, k2={:.3e} J/m^3'.format(k1, k2) + "\n\n")
64-
txt_output.insert(END, ' Magnetic susceptibility: {:.3e} m^3/kg'.format(np.mean(magnetic_susceptibility)) + "\n")
65-
66-
""" Print out key parameters
67-
print('\n Key Parameters \n\n')
68-
print(' Saturation moment: {:.3f} Am^2'.format(saturation_moment))
69-
print(' Coercivity: {:.3f} T'.format(coercivity))
70-
print(' Remanence: {:.3f} Am^2'.format(remanence))
71-
print(' Magnetic moment: {:.3f} Am^2'.format(magnetic_moment))
72-
print(' Anisotropy constants: k1={:.3e} J/m^3, k2={:.3e} J/m^3'.format(k1, k2))
73-
print(' Magnetic susceptibility: {:.3e} m^3/kg'.format(np.mean(magnetic_susceptibility)))
59+
txt_output.insert("end", " Key Parameters " + "\n\n")
60+
txt_output.insert("end", " Saturation moment: {:.3f} Am^2".format(saturation_moment) + "\n")
61+
txt_output.insert("end", " Coercivity: {:.3f} T".format(coercivity) + "\n")
62+
txt_output.insert("end", " Remanence: {:.3f} Am^2".format(remanence) + "\n")
63+
txt_output.insert("end", " Magnetic moment: {:.3f} Am^2".format(magnetic_moment) + "\n")
64+
txt_output.insert("end", " Anisotropy constants: k1={:.3e} J/m^3, k2={:.3e} J/m^3".format(k1, k2) + "\n\n")
65+
txt_output.insert("end", " Magnetic susceptibility: {:.3e} m^3/kg".format(np.mean(magnetic_susceptibility)) + "\n")
7466

75-
"""
67+
7668
plt.show() # show graph window
7769

7870

0 commit comments

Comments
 (0)