[update] array_map uses PylotCanvas now, added grid and labels

This commit is contained in:
Marcel Paffrath 2018-06-14 14:08:25 +02:00
parent 06cacdd4cb
commit fe0e4be43d
2 changed files with 12 additions and 13 deletions

View File

@ -2849,9 +2849,6 @@ class MainWindow(QMainWindow):
self.init_metadata() self.init_metadata()
if not self.metadata: if not self.metadata:
return return
self.am_figure = Figure()
self.am_canvas = PylotCanvas(self.am_figure, parent=self, panZoomX=False, panZoomY=False)
self.am_toolbar = NavigationToolbar(self.am_canvas, self)
self.array_map = Array_map(self) self.array_map = Array_map(self)
# self.array_map_thread() # self.array_map_thread()
self.array_layout.addWidget(self.array_map) self.array_layout.addWidget(self.array_map)

View File

@ -5,9 +5,9 @@ import matplotlib.pyplot as plt
import numpy as np import numpy as np
import obspy import obspy
from PySide import QtGui from PySide import QtGui
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar
from mpl_toolkits.basemap import Basemap from mpl_toolkits.basemap import Basemap
from pylot.core.util.widgets import PickDlg from matplotlib.figure import Figure
from pylot.core.util.widgets import PickDlg, PylotCanvas
from scipy.interpolate import griddata from scipy.interpolate import griddata
plt.interactive(False) plt.interactive(False)
@ -42,6 +42,7 @@ class Array_map(QtGui.QWidget):
self.init_x_y_dimensions() self.init_x_y_dimensions()
self.connectSignals() self.connectSignals()
self.draw_everything() self.draw_everything()
self.canvas.setZoomBorders2content()
def onpick(self, event): def onpick(self, event):
ind = event.ind ind = event.ind
@ -111,15 +112,12 @@ class Array_map(QtGui.QWidget):
def init_graphics(self): def init_graphics(self):
if not self.figure: if not self.figure:
if not hasattr(self._parent, 'am_figure'): self.figure = Figure()
self.figure = plt.figure()
self.toolbar = NavigationToolbar(self.figure.canvas, self)
else:
self.figure = self._parent.am_figure
self.toolbar = self._parent.am_toolbar
self.main_ax = self.figure.add_subplot(111) self.main_ax = self.figure.add_subplot(111)
self.canvas = self.figure.canvas self.canvas = PylotCanvas(self.figure, parent=self._parent, multicursor=True,
panZoomX=False, panZoomY=False)
#self.canvas.setZoomBorders2content()
self.main_box = QtGui.QVBoxLayout() self.main_box = QtGui.QVBoxLayout()
self.setLayout(self.main_box) self.setLayout(self.main_box)
@ -143,7 +141,6 @@ class Array_map(QtGui.QWidget):
self.top_row.setStretch(3, 1) # set stretch of item 1 to 1 self.top_row.setStretch(3, 1) # set stretch of item 1 to 1
self.main_box.addWidget(self.canvas) self.main_box.addWidget(self.canvas)
self.main_box.addWidget(self.toolbar)
def init_stations(self): def init_stations(self):
@ -236,6 +233,11 @@ class Array_map(QtGui.QWidget):
basemap.drawcountries(zorder=4) basemap.drawcountries(zorder=4)
basemap.drawstates(zorder=5) basemap.drawstates(zorder=5)
basemap.drawcoastlines(zorder=6) basemap.drawcoastlines(zorder=6)
# labels = [left,right,top,bottom]
parallels = np.arange(-90, 90, 5.)
basemap.drawparallels(parallels, labels=[True, True, False, False], zorder=7)
meridians = np.arange(-180, 180, 5.)
basemap.drawmeridians(meridians, labels=[False, False, True, True], zorder=7)
self.basemap = basemap self.basemap = basemap
self.figure.tight_layout() self.figure.tight_layout()