controlMatplotlib usage?

318 Views Asked by At

I need to embed a pyplot into a Pyform. Came across the ControlMatplotlib control but have struggled to get it to work. I am not sure what to set the value to.

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() 

Any insight is greatly appreciated.

1

There are 1 best solutions below

0
On
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)