I have a tool to show information extracted from various experiments and then
stored in a database. I would like to update a plot shown in the lower half
of the window when information such as the ranges of variables are modified
in the upper half. I can initially put data into the plot, however when I
want to change the contents (such as add another line to the plot), the
changes don't get displayed. Here is some code to illustrate the problem:
import matplotlib
matplotlib.rcParams['backend.qt4'] = 'PySide'
import matplotlib.pyplot as plt
from matplotlib.figure import Figure
matplotlib.use('Qt4Agg')
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as
FigureCanvas
from PySide import QtCore, QtGui
import sys
class TabDialog(QtGui.QDialog):
def __init__(self):
super(TabDialog, self).__init__()
tabWidget = QtGui.QTabWidget()
tabWidget.addTab(AnalyzeTab(), self.tr("Analyze"))
buttonLayout = QtGui.QHBoxLayout()
saveButton = QtGui.QPushButton(self.tr("Update"))
saveButton.clicked[bool].connect(self.update)
buttonLayout.addWidget(saveButton)
mainLayout = QtGui.QVBoxLayout()
mainLayout.addWidget(tabWidget)
mainLayout.addLayout(buttonLayout)
self.setLayout(mainLayout)
def update(self):
data.update()
class DataHolder():
def __init__(self):
self.gFig = Figure()
self.ax = self.gFig.add_subplot(111)
self.ax.plot([1,2,4,0.1])
self.canvas = FigureCanvas(self.gFig)
def update(self):
self.ax.plot([8,6,4,2])
class AnalyzeTab(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
analyzeLayout = QtGui.QGridLayout()
analyzeLayout.addWidget(data.canvas, 2, 0, 6, 8)
self.setLayout(analyzeLayout)
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
data = DataHolder()
tabdialog = TabDialog()
tabdialog.show()
sys.exit(app.exec_())
Any suggestions are very much appreciated.
···
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/Would-like-to-update-visible-plot-using-pyside-and-matplotlib-tp39576.html
Sent from the matplotlib - users mailing list archive at Nabble.com.