本文整理汇总了Python中matplotlib.backends.backend_qt4agg.NavigationToolbar2QT.pan方法的典型用法代码示例。如果您正苦于以下问题:Python NavigationToolbar2QT.pan方法的具体用法?Python NavigationToolbar2QT.pan怎么用?Python NavigationToolbar2QT.pan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_qt4agg.NavigationToolbar2QT
的用法示例。
在下文中一共展示了NavigationToolbar2QT.pan方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MatplotlibWidgetWFPot
# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QT import pan [as 别名]
class MatplotlibWidgetWFPot(QtGui.QGraphicsView):
def __init__(self, parent = None):
QtGui.QWidget.__init__(self, parent)
self.canvas = MplCanvas()
self.vbl = QtGui.QVBoxLayout()
self.vbl.addWidget(self.canvas)
self.setLayout(self.vbl)
self.canvas.ax.set_title('Calculated PCB electrode potentials', fontsize=10)
self.canvas.fig.patch.set_alpha(0)
self.mpl_toolbar = NavigationToolbar(self.canvas, self)
params = {
'legend.fontsize': 8,
'xtick.labelsize': 8,
'ytick.labelsize': 8,
'legend.handletextpad': .5,
}
plt.rcParams.update(params)
self.mpl_toolbar.pan()
def plot(self, wfPotentials, plotitems):
if hasattr(wfPotentials, 'plotTime'):
argX = wfPotentials.plotTime
argY = wfPotentials.potentialsOut
# get axis limits to not reset zoom/pan
axlim = self.canvas.ax.axis()
self.canvas.ax.clear()
if not any(plotitems):
self.canvas.draw()
return
if plotitems[0]:
self.canvas.ax.plot(argX, argY[1,:], 'r.')
self.canvas.ax.plot(argX, argY[1,:], 'r', label="2", linewidth=1.2)
if plotitems[1]:
self.canvas.ax.plot(argX, argY[3,:], 'b.')
self.canvas.ax.plot(argX, argY[3,:], 'b', label="4", linewidth=1.2)
if plotitems[2]:
self.canvas.ax.plot(argX, argY[5,:], 'g.')
self.canvas.ax.plot(argX, argY[5,:], 'g', label="6", linewidth=1.2)
if not axlim == (0.0, 1.0, 0.0, 1.0):
self.canvas.ax.axis(axlim)
else: pass
self.canvas.ax.grid(True)
self.canvas.ax.set_title("Calculated PCB electrode potentials", fontsize=10)
self.canvas.ax.set_xlabel("Time ($\mu$s)", fontsize=10)
self.canvas.ax.set_ylabel("Amplitude (bits)", fontsize=10)
self.canvas.ax.legend(bbox_to_anchor=(0.02, 0.99), loc=2, borderpad=None, borderaxespad=0., fontsize=8, frameon=False)
# mares in potential generation
self.canvas.ax.plot([wfPotentials.incplTime,wfPotentials.incplTime],[(wfPotentials.maxAmp*2+50),-50], 'k--', linewidth=1.5)
self.canvas.ax.plot([wfPotentials.plotTime[-1]-wfPotentials.outcplTime, wfPotentials.plotTime[-1]-wfPotentials.outcplTime], \
[-1,wfPotentials.maxAmp*2+1], 'k--', linewidth=1.5)
#self.WaveformDisplay.canvas.ax.plot([wfPotentials.incplTime+wfPotentials.decelTime,\
#wfPotentials.incplTime+wfPotentials.decelTime],[wfPotentials.maxAmp*-2-1, wfPotentials.maxAmp*2+1], 'k--', linewidth=1)
self.canvas.fig.patch.set_alpha(0)
self.canvas.fig.tight_layout()
self.canvas.draw()
else:
print 'No potentials generated'
示例2: pan
# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QT import pan [as 别名]
def pan(self, *args):
"""
:param args:
:return:
"""
NavigationToolbar2.pan(self, args)
if self._navigationMode == MyNavigationToolbar.NAVIGATION_MODE_PAN:
# out of pan mode
self._navigationMode = MyNavigationToolbar.NAVIGATION_MODE_NONE
else:
# into pan mode
self._navigationMode = MyNavigationToolbar.NAVIGATION_MODE_PAN
return
示例3: MainWindow
# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QT import pan [as 别名]
class MainWindow(QtGui.QMainWindow, mw.Ui_MainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.setupUi(self)
self.datalst = []
self.modellst = []
self.lstdatamodel = QtGui.QStandardItemModel(self.listView)
self.listView.setModel(self.lstdatamodel)
self.current_lst_index = -1
self.addButton.clicked.connect(self.add)
self.removeButton.clicked.connect(self.remove)
self.actionCalcLSSParameter.triggered.connect(self.calculatelss)
self.actionAutomaticElutionWindowStretching.triggered.connect(self.calcautelwindowstretch)
self.actionSelectivityMap.triggered.connect(self.pltselectivitymap)
self.actionResolutionMap.triggered.connect(self.pltresolutionmap)
self.actionAbout.triggered.connect(self.about)
self.actionQuit.triggered.connect(self.quit)
self.listView.clicked.connect(self.viewmatrix)
self.toolBox.currentChanged.connect(self.viewmatrix)
self.zoomButton.clicked.connect(self.zoom)
self.panButton.clicked.connect(self.pan)
self.rescaleButton.clicked.connect(self.home)
self.modelBox.currentIndexChanged.connect(self.gradientanalyser)
self.doubleSpinBox_1.valueChanged.connect(self.gradientanalyser)
self.doubleSpinBox_2.valueChanged.connect(self.gradientanalyser)
self.doubleSpinBox_3.valueChanged.connect(self.gradientanalyser)
self.doubleSpinBox_4.valueChanged.connect(self.gradientanalyser)
self.doubleSpinBox_5.valueChanged.connect(self.gradientanalyser)
self.ColumnLenghtSpinBox.valueChanged.connect(self.gradientanalyser)
self.CulumnDiameterSpinBox.valueChanged.connect(self.gradientanalyser)
self.ColumnPorositySpinBox.valueChanged.connect(self.gradientanalyser)
# Add plot
self.figure = plt.figure()
self.canvas = FigureCanvas(self.figure)
self.toolbar = NavigationToolbar(self.canvas, self)
self.toolbar.hide()
# set the layout
layout_chormatogram = QtGui.QVBoxLayout()
layout_chormatogram.addWidget(self.canvas)
self.plotterBox.setLayout(layout_chormatogram)
# Add selectivity map plot
#self.figure_smap = plt.figure()
#self.canvas_smap = FigureCanvas(self.figure_smap)
#self.toolbar_smap = NavigationToolbar(self.canvas_smap, self)
#self.toolbar_smap.hide()
#layout_smap = QtGui.QVBoxLayout()
#layout_smap.addWidget(self.canvas_smap)
#self.plotterBox_2.setLayout(layout_smap)
self.tablemodel = TableModel(self)
self.tableView.setModel(self.tablemodel)
self.tableView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.tableView.customContextMenuRequested.connect(self.openTableMenu)
# constant parameters
self.crit_resolution = 1.8
self.crit_alpha = 1.1
def openTableMenu(self, position):
""" context menu event """
menu = QtGui.QMenu(self)
exportAction = menu.addAction("Export table as CSV")
action = menu.exec_(self.tableView.viewport().mapToGlobal(position))
if action == exportAction:
fname = QtGui.QFileDialog.getSaveFileName(self, "Save File", "CSV (*.csv)");
#fname = QtGui.getSaveFileName.getOpenFileName(self, tr('Save File'), )
self.tablemodel.SaveTable(fname)
else:
return
return
def keyPressEvent(self, e):
if (e.modifiers() & QtCore.Qt.ControlModifier):
if e.key() == QtCore.Qt.Key_C: #copy
if len(self.tableView.selectionModel().selectedIndexes()) > 0:
previous = self.tableView.selectionModel().selectedIndexes()[0]
columns = []
rows = []
for index in self.tableView.selectionModel().selectedIndexes():
if previous.column() != index.column():
columns.append(rows)
rows = []
rows.append(str(index.data().toPyObject()))
previous = index
columns.append(rows)
# add rows and columns to clipboard
clipboard = ""
nrows = len(columns[0])
ncols = len(columns)
for r in xrange(nrows):
#.........这里部分代码省略.........
示例4: pan
# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QT import pan [as 别名]
def pan(self):
NavigationToolbar.pan(self)
self.mode = "" #<--- whatever you want to replace "pan/zoom" goes here
self.set_message(self.mode)
示例5: PyWeramiWindow
# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QT import pan [as 别名]
class PyWeramiWindow(QtGui.QMainWindow, Ui_MainWindow):
def __init__(self, filename=None, parent=None):
super(PyWeramiWindow,self).__init__(parent)
self.settings = QtCore.QSettings("LX", "pywerami")
self.setupUi(self)
self._fig = plt.figure(facecolor="white")
self._ax = self._fig.add_subplot(111)
self._canvas = FigureCanvas(self._fig)
self._canvas.setParent(self.widget)
self._canvas.setFocusPolicy(QtCore.Qt.StrongFocus)
self.matplot.addWidget(self._canvas)
self.mpl_toolbar = NavigationToolbar(self._canvas,self.widget)
self.mpl_toolbar.hide()
self.matplot.addWidget(self.mpl_toolbar)
#set combos
self.cmaps = [m for m in plt.cm.datad if not m.endswith("_r")]
self.mapstyle.addItems(self.cmaps)
# set validators
self.levelmin.setValidator(QtGui.QDoubleValidator(self.levelmin))
self.levelmax.setValidator(QtGui.QDoubleValidator(self.levelmax))
self.levelnum.setValidator(QtGui.QIntValidator(self.levelmin))
self.levelstep.setValidator(QtGui.QDoubleValidator(self.levelstep))
self.clipmin.setValidator(QtGui.QDoubleValidator(self.clipmin))
self.clipmax.setValidator(QtGui.QDoubleValidator(self.clipmax))
# Set icons in toolbar
self.actionOpen.setIcon(QtGui.QIcon.fromTheme('document-open'))
self.actionSave.setIcon(QtGui.QIcon.fromTheme('document-save'))
self.actionSaveas.setIcon(QtGui.QIcon.fromTheme('document-save-as'))
self.actionImport.setIcon(QtGui.QIcon.fromTheme('x-office-spreadsheet'))
self.actionHome.setIcon(self.mpl_toolbar._icon('home.png'))
self.actionPan.setIcon(self.mpl_toolbar._icon('move.png'))
self.actionZoom.setIcon(self.mpl_toolbar._icon('zoom_to_rect.png'))
self.actionGrid.setIcon(QtGui.QIcon.fromTheme('format-justify-fill'))
self.actionAxes.setIcon(self.mpl_toolbar._icon('qt4_editor_options.png'))
self.actionSavefig.setIcon(self.mpl_toolbar._icon('filesave.png'))
#self.action3D.setIcon(QtGui.QIcon.fromTheme(''))
self.actionProperties.setIcon(QtGui.QIcon.fromTheme('preferences-other'))
self.actionQuit.setIcon(QtGui.QIcon.fromTheme('application-exit'))
self.actionAbout.setIcon(QtGui.QIcon.fromTheme('help-about'))
self.actionImport.triggered.connect(self.import_data)
self.actionHome.triggered.connect(self.mpl_toolbar.home)
self.actionPan.triggered.connect(self.plotpan)
self.actionZoom.triggered.connect(self.plotzoom)
self.actionGrid.triggered.connect(self.plotgrid)
self.actionAxes.triggered.connect(self.mpl_toolbar.edit_parameters)
self.actionSavefig.triggered.connect(self.mpl_toolbar.save_figure)
self.actionProperties.triggered.connect(self.edit_options)
self.actionQuit.triggered.connect(self.close)
if filename:
self.import_data(filename)
# ready
self.statusbar.showMessage("Ready", 5000)
def closeEvent(self,event):
reply=QtGui.QMessageBox.question(self,'Message',"Are you sure to quit?",QtGui.QMessageBox.Yes,QtGui.QMessageBox.No)
if reply==QtGui.QMessageBox.Yes:
event.accept()
else:
event.ignore()
def import_data(self, filename=None):
if not filename:
filename = QtGui.QFileDialog.getOpenFileName(self, "Import tab file", ".", "TAB (*.tab);;All files (*.*)")
if filename:
self.data = WeramiData.from_tab(filename)
# populate listview and setup properties
self.props = {}
self._model = QtGui.QStandardItemModel(self.listView)
for var in self.data.dep:
item = QtGui.QStandardItem(var)
item.setCheckable(True)
self._model.appendRow(item)
self.default_var_props(var)
self.listView.setModel(self._model)
self.listView.show()
# connect listview signals
self.varSel = self.listView.selectionModel()
self.varSel.selectionChanged.connect(self.on_var_changed)
self._model.itemChanged.connect(self.plot)
# buttons signals
self.buttonBox.button(QtGui.QDialogButtonBox.Apply).clicked.connect(self.apply_props)
self.buttonBox.button(QtGui.QDialogButtonBox.RestoreDefaults).clicked.connect(self.restore_props)
self.contcolor.clicked.connect(self.contours_color)
self.action3D.triggered.connect(self.switch3d)
# signals to calculate step size
self.levelmin.editingFinished.connect(self.step_from_levels)
self.levelmax.editingFinished.connect(self.step_from_levels)
self.levelnum.editingFinished.connect(self.step_from_levels)
self.setlevels.toggled.connect(self.step_from_levels)
# all done focus
#.........这里部分代码省略.........
示例6: pan
# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QT import pan [as 别名]
def pan(self):
if self._active != 'PAN':
self.toogle_off_all_active()
NavigationToolbar.pan(self)
示例7: Window
# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QT import pan [as 别名]
#.........这里部分代码省略.........
def comboActivated(self, text):
self.tag = text
self.data = self.b.getvar(self.tag)
self.plot()
def reset_bifrost_obj(self):
self.b, self.base_name, self.snap_n = get_bifrost_obj(self.fpath,0,self.check_aux.isChecked())
print self.b.snapvars
self.get_data()
def get_data(self):
self.data = self.b.getvar(self.tag)
if self.view == 'X-Y':
self.slide_dimension = 2
elif self.view == 'X-Z':
self.slide_dimension = 1
elif self.view == 'Y-Z':
self.slide_dimension = 0
self.slider.setMinimum(0)
self.slider.setMaximum(self.data.shape[self.slide_dimension]-1)
if self.slider.value() >= self.data.shape[self.slide_dimension]:
self.slider.setValue(self.data.shape[self.slide_dimension]-1)
elif self.slider.value() < 0:
self.slider.setValue(0)
self.setCombo()
def home(self):
self.toolbar.home()
def zoom(self):
self.toolbar.zoom()
def pan(self):
self.toolbar.pan()
def plot(self):
plt.clf()
ax = self.figure.add_subplot(111)
slice_str = '[?]'
# extension = []
if self.view == 'X-Y':
image = self.data[:,:,self.slider.value()]
slice_str = 'z = %f ' % self.b.z[self.slider.value()]
ax.set_ylabel('y-direction')
ax.set_xlabel('x-direction')
# extension = [0, self.param['mx'], 0, self.param['my']]
elif self.view == 'X-Z':
image = self.data[:,self.slider.value(),:]
slice_str = 'y = %f ' % self.b.y[self.slider.value()]
ax.set_ylabel('z-direction')
ax.set_xlabel('x-direction')
# extension = [0, self.param['mx'], 0, self.param['mz']]
elif self.view == 'Y-Z':
image = self.data[self.slider.value(),:,:]
slice_str = 'x = %f ' % self.b.x[self.slider.value()]
ax.set_ylabel('z-direction')
ax.set_xlabel('y-direction')
# extension = [0, self.param['my'], 0, self.param['mz']]
# image = np.fliplr(image)
# image = np.rot90(image,k=3)
label = "Value"
color = cm.get_cmap('jet')
ax.set_title("[%s] %s (Snap: %s) for %s \n[time: %s]" % (self.tag, self.base_name, self.snap_n, slice_str, str(datetime.timedelta(seconds=self.param['t']*self.param['u_t']))))
示例8: MatplotlibWidgetWL
# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QT import pan [as 别名]
class MatplotlibWidgetWL(QGraphicsView):
def __init__(self, parent = None):
QWidget.__init__(self, parent)
self.canvas = MplCanvas()
self.vbl = QVBoxLayout()
self.vbl.addWidget(self.canvas)
self.setLayout(self.vbl)
self.canvas.ax.set_title('Series of Averages', fontsize=12)
self.canvas.fig.patch.set_alpha(0)
self.canvas.fig.tight_layout()
self.mpl_toolbar = NavigationToolbar(self.canvas, self)
self.canvas.mpl_connect('button_press_event', self.onclick)
self.mpl_toolbar.pan()
params = {
'xtick.labelsize': 12,
'ytick.labelsize': 12,
'figure.autolayout': True,
}
plt.rcParams.update(params)
self.data = []
self.distmeshsurf = 1.
if sys.platform == 'darwin':
self.filePath = '/Users/TPSGroup/Documents/Experimental Data/Data Mike/Raw Data/2015'
else:
self.filePath = 'C:\\Users\\tpsgroup\\Desktop\\Documents\\Data Mike\\Raw Data\\2015'
self.trace = [False, False, False, False]
pickedValReady = pyqtSignal(object)
def onclick(self, event):
if event.button == 3:
self.pickedValReady.emit(event.xdata)
def addTrace(self):
# average traces saved as (paramter, surface, surface err, field, field err)
datapath = QFileDialog.getOpenFileNames(self, 'Select Avgerage Trace File', self.filePath, '(*.txt)')
if not datapath: return
for i in range(len(datapath)):
self.data.append(loadtxt(str(datapath[i]), skiprows=2))
self.filePath = os.path.dirname(str(datapath[0]))
def kRange(self, n, ml):
'''Stark states in parabolic quantum number k(n_1-n_2), {k}=-(n-|m_l|-1)...(n-|m_l|-1),
(n-|m_l|) elements, elements the same for m_l=0, +/-2 where maxkmax states have pure m_l=0
character, these two states are 'missing' at the edge of the manifold for m_l=+/-2'''
kRange = [i for i in range(-(n-abs(ml)-1),(n-abs(ml)),2)]
return kRange
def StarkEnergy(self, n, ml, k, F):
# Hartree in wavenumbers, Rydberg constant in cm^-1
# Rydberg constant for Hydrogen != R_inf
rh = 109677.583
hartree = 2*rh
Eau = (-(1./(2*n**2)) + 1.5*n*k*F - (n**4)/16.0*(17*n**2 - 3*k**2 - 9*ml**2 + 19)*F**2 + \
3/32*n**7*k*(23*n**2 - k**2 + 11*ml**2 + 39)*F**3 - \
(n**10)/1024.0*(5487*n**4 + 35182*n**2 - 1134*ml**2*k**2 + \
1806*n**2*k**2 - 3402*n**2*ml**2 - 3093*k**4 - 549*ml**4 + \
5754*k**2 - 8622*ml**2 + 16211)*F**4)*hartree
return Eau
def plotSpectrum(self, n, ml02j32flag, ml1j32flag, ml02j12flag, ml1j12flag, trace, d, volt, offset, smooth, smoothwin, smoothpol, normalise):
if len(self.data) < 1: return
# get curent xy limits
xlim1, xlim2 = self.canvas.ax.get_xlim()
ylim1, ylim2 = self.canvas.ax.get_ylim()
self.canvas.ax.clear()
self.distmeshsurf = d
# build Stark manifold from expansion for energies in E-field
# from http://physics.nist.gov/asd
Lalphaj32 = -82259.2850014 #121.5668237310
Lalphaj12 = -82258.919113 #121.5673644609
rh = 109677.583
c = 299792458
# in eV
h = 4.135667662E-15
# Electric field in V/cm to atomic units E_h/ea_0.
#http://physics.nist.gov/cgi-bin/cuu/Value?auefld
Fau = (100*volt/(5.142206E11))/d
# energies converted to nm
# account for fine splitting due to spin-orbit coupling
# if not, from expansion: en = (2*10**7)/(self.StarkEnergy(n, 2, k, Fau) - self.StarkEnergy(2, 0, 1, Fau)) + offset
kml02 = self.kRange(n, 0)
kml1 = self.kRange(n, 1)
if ml02j32flag:
ml02j32 = [0]*len(kml02)
for i in range(len(kml02)):
ml02j32[i] = (2*10**7)/(self.StarkEnergy(n, 2, kml02[i], Fau) - (-rh-Lalphaj32)) + offset
if ml1j32flag:
ml1j32 = [0]*len(kml1)
for i in range(len(kml1)):
ml1j32[i] = (2*10**7)/(self.StarkEnergy(n, 1, kml1[i], Fau) - (-rh-Lalphaj32)) + offset
if ml02j12flag:
ml02j12 = [0]*len(kml02)
for i in range(len(kml02)):
ml02j12[i] = (2*10**7)/(self.StarkEnergy(n, 2, kml02[i], Fau) - (-rh-Lalphaj12)) + offset
if ml1j12flag:
ml1j12 = [0]*len(kml1)
for i in range(len(kml1)):
ml1j12[i] = (2*10**7)/(self.StarkEnergy(n, 1, kml1[i], Fau) - (-rh-Lalphaj12)) + offset
#.........这里部分代码省略.........
示例9: MatplotlibWidgetRydSeries
# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QT import pan [as 别名]
class MatplotlibWidgetRydSeries(QGraphicsView):
def __init__(self, parent = None):
QWidget.__init__(self, parent)
self.canvas = MplCanvas()
self.vbl = QVBoxLayout()
self.vbl.addWidget(self.canvas)
self.setLayout(self.vbl)
self.canvas.ax.set_title('Rydberg Series', fontsize=12)
self.canvas.setFocusPolicy(Qt.StrongFocus)
self.canvas.setFocus()
self.canvas.fig.patch.set_alpha(0)
self.mpl_toolbar = NavigationToolbar(self.canvas, self)
params = {
'legend.fontsize': 12,
'xtick.labelsize': 12,
'ytick.labelsize': 12,
'legend.handletextpad': .5,
'figure.autolayout': True,
}
plt.rcParams.update(params)
self.canvas.mpl_connect('button_press_event', self.onclick)
self.mpl_toolbar.pan()
self.clearflag = False
self.defaultloaded = False
self.filePath = 'C:\\Users\\tpsgroup\\Desktop\\Documents\\Data Mike'
pickedValReady = pyqtSignal(object)
def defaultSet(self, bool):
self.defaultloaded = bool
def plotWLScan(self,laseroffset):
'''display complete WL scan and Rydberg series on top'''
dataField = loadtxt('FullWavelengthScanField.txt')
dataSurface = loadtxt('FullWavelengthScanSurface.txt')
argYField = dataField[:,1]/max(dataField[:,1])
argYSurface = dataSurface[:,1]/max(dataSurface[:,1])
self.canvas.ax.clear()
self.canvas.ax.plot(dataField[:,0], argYField, 'k', label="Field Signal", linewidth=1.5)
self.canvas.ax.plot(dataSurface[:,0], argYSurface, 'g', label="Surface Signal", linewidth=1.5)
self.canvas.ax.set_xlabel("Fundamental Wavelength (nm)", fontsize=12)
self.canvas.ax.set_title('Rydberg Series', fontsize=12)
self.canvas.ax.legend(loc="upper right", bbox_to_anchor = [.98,0.86], fontsize=12)
self.canvas.ax.set_ylim([-0.02,1.12])
self.plotRydSeries(laseroffset)
self.canvas.fig.tight_layout()
self.canvas.draw()
self.defaultloaded = True
def addTrace(self):
datapath = QFileDialog.getOpenFileName(self, 'Select WL Scan File', self.filePath, '(*.txt)')
if not datapath: return
self.filePath = os.path.dirname(str(datapath))
if len(datapath) < 1: return
data = loadtxt(str(datapath))
argY = data[:,1]/max(data[:,1])
if self.defaultloaded:
self.canvas.ax.plot(data[:,0], argY, 'r', label="Field Signal", linewidth=1.5)
else:
self.canvas.ax.plot(data[:,0], argY, 'k', label="Field Signal", linewidth=1.5)
self.canvas.draw()
def clearDisplay(self):
self.canvas.ax.cla()
self.canvas.draw()
self.clearflag = True
self.defaultloaded = False
def onclick(self, event):
if event.button == 3:
self.pickedValReady.emit(event.xdata)
def plotRydSeries(self, laseroffset):
# Rydberg constant for Hydrogen
rh = 109677.583
nRange = np.arange(15, 71)
j32offset = 0.091 # 1/64*alpha^2*Ryd
rydEn = (2.*10**7)/(rh*(0.25 - (1./nRange**2)) - j32offset) + laseroffset
if not(self.clearflag):
if hasattr(self, 'rydlines') and len(self.canvas.ax.lines) > 0:
for i in range(np.size(self.rydlines)):
self.canvas.ax.lines.remove(self.rydlines[i])
if hasattr(self, 'rydlabels') and len(self.canvas.ax.texts) > 0:
for i in range(np.size(self.rydlines)):
self.rydlabels[i].remove()
xx = (rydEn, rydEn)
yy = (np.ones(np.size(rydEn))*-0.02,np.ones(np.size(rydEn))*1.02)
self.rydlines = self.canvas.ax.plot(xx,yy,linewidth=1,color='b')
labels = nRange.astype(str)
self.rydlabels = {}
for i in range(np.size(labels)):
self.rydlabels[i] = self.canvas.ax.text(rydEn[i], 1.06, labels[i],
horizontalalignment='center',verticalalignment='center',color='b',fontsize=12)
self.canvas.draw()
self.clearflag = False