class Myplot(FigureCanvas):
def __init__(self, parent=None):
self.fig = Figure()
FigureCanvas.__init__(self, self.fig)
# self.hist()
def compute_initial_figure(self):
self.axes = self.fig.add_subplot(1,1,1)
self.axes.hold(False)
self.axes.plot(np.random.rand(400))
def hist(self):
tm = pd.Series(np.random.randn(500), index=pd.date_range('1/1/2005', periods=500))
self.axes = self.fig.add_subplot(1,1,1)
self.axes.hold(False)
tm = tm.cumsum()
self.axes.plot(tm)
class Panel (QtGui.QListWidget):
def __init__(self, parent=None):
QtGui.QListWidget.__init__(self)
self.row1 = "COMMISSIONS & FEES"
self.addItem(self.row1)
row2 = "NET LIQUIDATING VALUE"
self.addItem(row2)
self.setFixedWidth(200)
self.itemClicked.connect(self.Clicked)
def Clicked(self):
mplot=Myplot()
index=self.currentRow()
if index == 0:
print '0000'
mplot.compute_initial_figure()
if index == 1:
mplot.hist()
class Myplot(QtGui.QWidget):
def __init__(self, parent=None):
super(Myplot, self).__init__(parent)
# a figure instance to plot on
self.figure = plt.figure()
# this is the Canvas Widget that displays the `figure`
# it takes the `figure` instance as a parameter to __init__
self.canvas = FigureCanvas(self.figure)
self.mylist=QListWidget(self)
row1="COMMISSIONS & FEES"
self.mylist.addItem(row1)
row2="NET LIQUIDATING VALUE"
self.mylist.addItem(row2)
self.mylist.setFixedWidth(200)
self.mylist.itemClicked.connect(self.Clicked)
# set the layout
minlayout = QtGui.QHBoxLayout()
minlayout.addWidget(self.mylist)
minlayout.addWidget(self.canvas)
self.setLayout(minlayout)
# self.hist()
def compute_initial_figure(self):
# random data
xdata = [random.random() for i in range(10)]
# create an axis
ax = self.figure.add_subplot(111)
# discards the old graph
ax.hold(False)
# plot data
ax.plot(xdata)
# refresh canvas
self.canvas.draw()
def hist(self):
tm = pd.Series(np.random.randn(500), index=pd.date_range('1/1/2005', periods=500))
tm = tm.cumsum()
ax = self.figure.add_subplot(111)
ax.hold(False)
ax.plot(tm)
self.canvas.draw()
def Clicked(self):
index=self.mylist.currentRow()
if index == 0:
print '0000'
self.compute_initial_figure()
if index == 1:
print '1111'
self.hist()