added class MPLWidget in order to create updatable Matplotlib Figures within a Qt GUI
This commit is contained in:
parent
8edea03fe7
commit
9a2d127e30
29
pylot/core/util/widgets.py
Normal file
29
pylot/core/util/widgets.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
Created on Wed Mar 19 11:27:35 2014
|
||||||
|
|
||||||
|
@author: sebastianw
|
||||||
|
"""
|
||||||
|
|
||||||
|
import matplotlib
|
||||||
|
|
||||||
|
matplotlib.use('Qt4Agg')
|
||||||
|
matplotlib.rcParams['backend.qt4'] = 'PySide'
|
||||||
|
|
||||||
|
from matplotlib.figure import Figure
|
||||||
|
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg
|
||||||
|
|
||||||
|
|
||||||
|
class MPLWidget(FigureCanvasQTAgg):
|
||||||
|
|
||||||
|
def __init__(self, parent=None, xlabel='x', ylabel='y', title='Title'):
|
||||||
|
super(MPLWidget, self).__init__(Figure())
|
||||||
|
|
||||||
|
self.setParent(parent)
|
||||||
|
self.figure = Figure()
|
||||||
|
self.canvas = FigureCanvasQTAgg(self.figure)
|
||||||
|
self.axes = self.figure.add_subplot(111)
|
||||||
|
|
||||||
|
self.axes.set_xlabel(xlabel)
|
||||||
|
self.axes.set_ylabel(ylabel)
|
||||||
|
self.axes.set_title(title)
|
Loading…
Reference in New Issue
Block a user