SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: troyrock <tro...@ro...> - 2012年10月22日 23:04:27
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.
From: troyrock <tro...@ro...> - 2012年10月22日 23:22:25
I figured out the problem. I need to call self.canvas.draw() in order to
update the image. Sorry for the email.
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/Would-like-to-update-visible-plot-using-pyside-and-matplotlib-tp39576p39577.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /