controlMatplotlib用法?

时间:2018-04-08 13:34:09

标签: python matplotlib pyforms

我需要将一个pyplot嵌入到Pyform中。遇到了ControlMatplotlib控件但很难让它运行起来。我不确定将值设置为什么。

class SimpleExample(BaseWidget):
    def __init__(self):
        super(SimpleExample, self).__init__('Simple example')


        self._graph = ControlMatplotlib("plot")
        self.formset = [' ', (' ', '_graph', ' '), ' ']

        X = [i for i in range(0,100,2)]
        Y = [i for i in range(0,150,3)]


        pplot.scatter(X, Y)

        self._graph.value = ??
        self._graph.draw() 

非常感谢任何见解。

1 个答案:

答案 0 :(得分:0)

class SimpleExample(BaseWidget):
    def __init__(self):
        super().__init__('Simple example')
        self._scatter_plot = ControlMatplotlib()
        self._scatter_plot.value = plot_data


def plot_data(figure):
    axes = figure.add_subplot(111)
    X = [i for i in range(0, 100, 2)]
    Y = [i for i in range(0, 150, 3)]
    axes.scatter(X, Y)


if __name__ == '__main__':
    start_app(SimpleExample)