<s> """<STR_LIT>""" <EOL> from __future__ import division <EOL> import sys <EOL> from PyQt4 . QtCore import * <EOL> from PyQt4 . QtGui import * <EOL> import numpy as np <EOL> from matplotlib . backends . backend_qt4agg import FigureCanvasQTAgg as FigureCanvas <EOL> from matplotlib . backends . backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar <EOL> from matplotlib . figure import Figure <EOL> import matplotlib . pyplot as plt <EOL> class MatplotlibWidget ( QWidget ) : <EOL> def __init__ ( self , parent = None , grid = True ) : <EOL> QWidget . __init__ ( self , parent ) <EOL> self . grid = grid <EOL> self . fig = Figure ( ) <EOL> self . canvas = FigureCanvas ( self . fig ) <EOL> self . canvas . setParent ( self ) <EOL> self . canvas . mpl_connect ( '<STR_LIT>' , self . onPick ) <EOL> margins = [ <NUM_LIT> , <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT> ] <EOL> self . axes = self . fig . add_axes ( margins ) <EOL> self . toolbar = NavigationToolbar ( self . canvas , self ) <EOL> layout = QVBoxLayout ( ) <EOL> layout . addWidget ( self . toolbar ) <EOL> layout . addWidget ( self . canvas ) <EOL> self . setLayout ( layout ) <EOL> def onPick ( self , event ) : <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' , event . button , event . xdata , event . ydata <EOL> def update ( self ) : <EOL> self . canvas . draw ( ) <EOL> def plot ( self , * args , ** kwargs ) : <EOL> self . axes . plot ( * args , ** kwargs ) <EOL> self . axes . grid ( self . grid ) <EOL> self . update ( ) <EOL> def clear ( self ) : <EOL> self . axes . clear ( ) <EOL> def initFigure ( self ) : <EOL> self . axes . grid ( True ) <EOL> x = np . linspace ( - <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> y = x ** <NUM_LIT:2> <EOL> self . axes . plot ( x , y , '<STR_LIT>' ) <EOL> class PlotWindow ( QMainWindow ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , parent = None ) : <EOL> super ( PlotWindow , self ) . __init__ ( parent ) <EOL> self . setAttribute ( Qt . WA_DeleteOnClose ) <EOL> self . mplWidget = MatplotlibWidget ( ) <EOL> self . setCentralWidget ( self . mplWidget ) <EOL> def plot ( self , dataFrame ) : <EOL> '''<STR_LIT>''' <EOL> dataFrame . plot ( ax = self . mplWidget . axes ) <EOL> def getAxes ( self ) : <EOL> return self . mplWidget . axes <EOL> def getFigure ( self ) : <EOL> return self . mplWidget . fig <EOL> def update ( self ) : <EOL> self . mplWidget . update ( ) <EOL> class MainForm ( QMainWindow ) : <EOL> def __init__ ( self , parent = None ) : <EOL> QMainWindow . __init__ ( self , parent ) <EOL> self . setWindowTitle ( '<STR_LIT>' ) <EOL> self . plot = MatplotlibWidget ( ) <EOL> self . setCentralWidget ( self . plot ) <EOL> self . plot . clear ( ) <EOL> self . plot . plot ( np . random . rand ( <NUM_LIT:10> ) , '<STR_LIT>' ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> app = QApplication ( sys . argv ) <EOL> form = MainForm ( ) <EOL> form . show ( ) <EOL> app . exec_ ( ) </s>
