This small example builds on the example found at:
http://caethan.wordpress.com/2011/09/05/chaco-plots-in-pyside/
This example can be extended to easily include multiple plots and the adjustment of
plot parameters using spin boxes.
#!/usr/bin/python import sys from numpy import * from PySide.QtCore import * from PySide.QtGui import * app = QApplication(sys.argv) from traits.etsconfig.etsconfig import ETSConfig ETSConfig.toolkit = "qt4" from enable.api import Window from chaco.api import ArrayPlotData, Plot class Viewer(QMainWindow): def __init__(self): QMainWindow.__init__(self) self.mainWidget = QWidget(self) # dummy widget to contain layout manager self.plotview = Plotter(self) self.setCentralWidget(self.mainWidget) self.amplitudeLabel = QLabel("Amplitude: ") self.amplitudeSpinBox = QDoubleSpinBox() self.amplitudeSpinBox.setRange(-1000000.00, 1000000.00) self.amplitudeSpinBox.setValue(1.00) self.plotButton = QPushButton("Plot") self.plotButton.clicked.connect(self.update) self.statusBar().showMessage('Ready to rock!') self.setWindowTitle('sin(x)') x = arange(100) y = zeros(100) self.plotview.update_data(x, y) layout = QVBoxLayout(self.mainWidget) layout.addWidget(self.amplitudeLabel) layout.addWidget(self.amplitudeSpinBox) layout.addWidget(self.plotButton) layout.addWidget(self.plotview.widget) self.setLayout(layout) def update(self): print "Ok" print self.amplitudeSpinBox.value() x = arange(200) y = self.amplitudeSpinBox.value() * sin(x) self.plotview.update_data(x, y) class Plotter(): def __init__(self, parent): self.plotdata = ArrayPlotData(x=array([]), y=array([])) self.window = self.create_plot(parent) self.widget = self.window.control def update_data(self, x, y): self.plotdata.set_data("x", x) self.plotdata.set_data("y", y) def create_plot(self, parent): plot = Plot(self.plotdata, padding=50, border_visible=True) plot.plot(("x", "y"), name="data plot", color="green") return Window(parent, -1, component=plot) if __name__ == "__main__": plot = Viewer() plot.resize(600, 400) plot.show() sys.exit(app.exec_())
ReplyDeleteThis information was very useful to me and I thank you for this.keep sharing more like this.
ccna course in Chennai
ccna institute in Chennai
Python course in Chennai
Python Training Institute in Chennai
Angularjs Training institute in Chennai
ccna Training in OMR
ccna Training in Adyar
They are constantly proactive and design agencies SF invested in the success of the project.
ReplyDeleteThey were quick to incorporate feedback and were open with their progress throughout the project
ReplyDeletetop creative agencies
They did a good job of listening to what we were looking to build but also pushing us beyond what we had thought of
ReplyDeleteapp designers
The team managed the project excellently, and they were an extremely skilled design partner.
ReplyDeleteuser interface design company
Their team successfully implemented improved features, contributing to the client's needed outcome.
ReplyDeletebest UI design
Thank you I am glad about the encouragement! I love your site, you post outstanding.
ReplyDeleteweb design firm
Good blog along with the excellent quality stuff and I’m sure this will be greatly helpful.
ReplyDeletelogo making companies
Hi Dear, have you been certainly visiting this site daily, if that's the case you then will certainly get good knowledge.
ReplyDeletebest web design agency
Whatever you have provided for us in these posts really appreciative.
ReplyDeleteweb design and development agency
Your blog is extremely brilliant especially the quality content is really appreciable.
ReplyDeleteexperience design agency
The complete blogs are really inconceivable and definitely everyone will share this information.
ReplyDeletebest UI UX design companies
How to Download and Activate Movavi Video Editor Plus? · Select any key from the product key passage and go to the 'Help' section of the software Activation Key For Movavi
ReplyDelete