当前位置: 首页>>代码示例>>Python>>正文


Python Plot.set_data方法代码示例

本文整理汇总了Python中plot.Plot.set_data方法的典型用法代码示例。如果您正苦于以下问题:Python Plot.set_data方法的具体用法?Python Plot.set_data怎么用?Python Plot.set_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在plot.Plot的用法示例。


在下文中一共展示了Plot.set_data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Window

# 需要导入模块: from plot import Plot [as 别名]
# 或者: from plot.Plot import set_data [as 别名]

#.........这里部分代码省略.........
        self.beta_input.textChanged[str].connect(self.change_argument)
        self.update_button.clicked.connect(self.update_animation)

        layout = QtGui.QVBoxLayout(self)

        splitter1 = QtGui.QSplitter(Qt.Vertical)
        splitter1.addWidget(self.lbl1)
        splitter1.addWidget(self.acceleration_input)
        splitter1.addWidget(self.lbl2)
        splitter1.addWidget(self.l1_input)
        splitter1.addWidget(self.lbl3)
        splitter1.addWidget(self.l2_input)
        splitter1.addWidget(self.lbl4)
        splitter1.addWidget(self.m1_input)
        splitter1.addWidget(self.lbl5)
        splitter1.addWidget(self.m2_input)
        splitter1.addWidget(self.lbl7)
        splitter1.addWidget(self.alpha_input)
        splitter1.addWidget(self.lbl8)
        splitter1.addWidget(self.beta_input)
        splitter1.addWidget(self.lbl6)
        splitter1.addWidget(self.r0)
        splitter1.addWidget(self.r1)
        splitter1.addWidget(self.r2)
        splitter1.addWidget(self.r3)
        splitter1.addWidget(self.update_button)
        # splitter1.addWidget(left)

        splitter0 = QtGui.QSplitter(Qt.Horizontal)
        splitter0.addWidget(splitter1)

        splitter2 = QtGui.QSplitter(Qt.Vertical)
        splitter2.addWidget(self.toolbar)
        splitter2.addWidget(self.canvas)

        splitter0.addWidget(splitter2)

        layout.addWidget(splitter0)

        self.setLayout(layout)
        self.p = Plot(self.figure, self.data)

    def init_radio(self):
        radio_group = QtGui.QButtonGroup(self.radio_widget)
        self.r0 = QtGui.QRadioButton("10s")
        self.r1 = QtGui.QRadioButton("25s")
        self.r2 = QtGui.QRadioButton("50s")
        self.r3 = QtGui.QRadioButton("100s")

        radio_group.addButton(self.r0)
        radio_group.addButton(self.r1)
        radio_group.addButton(self.r2)
        radio_group.addButton(self.r3)

        self.r0.toggled.connect(self.set_animation_time)
        self.r1.toggled.connect(self.set_animation_time)
        self.r2.toggled.connect(self.set_animation_time)
        self.r3.toggled.connect(self.set_animation_time)

        self.r0.toggle()

    def set_animation_time(self):
        if self.r0.isChecked():
            self.animation_time = 10.0
        elif self.r1.isChecked():
            self.animation_time = 25.0
        elif self.r2.isChecked():
            self.animation_time = 50.0
        elif self.r3.isChecked():
            self.animation_time = 100.0
        else:
            print("Fatal error occured!")

    def change_argument(self, text):
        try:
            argument = float(text)
            if self.acceleration_input.senderSignalIndex() > 0:
                self.G = argument
            elif self.l1_input.senderSignalIndex() > 0:
                print(self.L1)
                self.L1 = argument
            elif self.l2_input.senderSignalIndex() > 0:
                self.L2 = argument
            elif self.m1_input.senderSignalIndex() > 0:
                self.M1 = argument
            elif self.m2_input.senderSignalIndex() > 0:
                self.M2 = argument
            elif self.alpha_input.senderSignalIndex() > 0:
                self.alpha = argument
            elif self.beta_input.senderSignalIndex() > 0:
                self.beta = argument
            else:
                print("Fatal error occured!")
        except:
            print("Wrong input")

    def update_animation(self):
        self.data.set_data(self.G, self.L1, self.L2, self.M1, self.M2, self.alpha, self.beta, self.animation_time)
        self.p.set_data(self.data.get_data())
        self.p.plot_animation(self.canvas)
开发者ID:matwoosh,项目名称:DoublePendulum,代码行数:104,代码来源:app.py


注:本文中的plot.Plot.set_data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。